Advertisement
nikolapetkov824

FilmStudioUnitTest

Jul 6th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const FilmStudio = require('./filmStudio.js');
  2.  
  3. const expect = require('chai').expect;
  4.  
  5. describe("Tests …", function () {
  6.     let fs;
  7.     beforeEach(() => {
  8.         fs = new FilmStudio('name');
  9.     })
  10.     describe("cotr", function () {
  11.         it("should return name", function () {
  12.             const expectedName = 'name';
  13.             const actualName = fs.name;
  14.             const expected = 0;
  15.             const actual = fs.films.length;
  16.  
  17.             expect(expectedName).to.equal(actualName);
  18.             expect(expected).to.equal(actual);
  19.         });
  20.  
  21.         // it("should return empty array", function () {
  22.         //     const expected = 0;
  23.         //     const actual = fs.films.length;
  24.         //     expect(expected).to.equal(actual);
  25.         // });
  26.     });
  27.     describe("casting", function () {
  28.         it("should return no films", function () {
  29.             const actual = `There are no films yet in ${fs.name}.`;
  30.             const expected = fs.casting('A', 'B');
  31.             expect(expected).to.equal(actual);
  32.         });
  33.  
  34.         it("should return no roles for actor", function () {
  35.             fs.makeMovie('The Avengers', ['Iron-Man', 'Thor', 'Hulk', 'Arrow guy']);
  36.             const actor = 'A';
  37.             const role = 'B';
  38.             const actual = `${actor}, we cannot find a ${role} role...`;
  39.             const expected = fs.casting('A', 'B');
  40.             expect(expected).to.equal(actual);
  41.         });
  42.  
  43.         it("should return actor got the job", function () {
  44.             fs.makeMovie('The Avengers', ['Iron-Man', 'Thor', 'Hulk', 'Arrow guy']);
  45.             const actual = 'You got the job! Mr. A you are next Iron-Man in the The Avengers. Congratz!';
  46.             const expected = fs.casting('A', 'Iron-Man');
  47.             expect(expected).to.equal(actual);
  48.         });
  49.     });
  50.  
  51.     describe("makeMovie", function () {
  52.         it("should return film", function () {
  53.             const expected = {
  54.                 filmName: 'The Avengers',
  55.                 filmRoles: [
  56.                     { role: 'Iron-Man', actor: false },
  57.                     { role: 'Thor', actor: false },
  58.                     { role: 'Hulk', actor: false },
  59.                     { role: 'Arrow guy', actor: false }]
  60.             };
  61.  
  62.             const actual = fs.makeMovie('The Avengers', ['Iron-Man', 'Thor', 'Hulk', 'Arrow guy']);
  63.             expect(expected).to.deep.equal(actual);
  64.         });
  65.  
  66.         it("should return error msg: invalid arguments", function () {
  67.             expect(() => fs.makeMovie('The Avengers', 1)).to.throw("Invalid arguments");
  68.         });
  69.  
  70.         it("should return error msg: invalid arguments count", function () {
  71.             expect(() => fs.makeMovie('The Avengers', 1, 'book')).to.throw("Invalid arguments count");
  72.         });
  73.     });
  74.  
  75.     describe("lookForProducer", function () {
  76.         it("should return toString", function () {
  77.             fs.makeMovie('The Avengers', ['Iron-Man', 'Thor']);
  78.             fs.casting('Johnny Depp', 'Iron-Man');
  79.             fs.casting('Kit Harington', 'Thor');
  80.  
  81.             let expected = 'Film name: The Avengers\n';
  82.             expected += 'Cast:\n';
  83.             expected += 'Johnny Depp as Iron-Man\n';
  84.             expected += 'Kit Harington as Thor\n';
  85.  
  86.             const actual = fs.lookForProducer('The Avengers');
  87.             expect(expected).to.deep.equal(actual);
  88.         });
  89.  
  90.         it("should return error msg: invalid arguments", function () {
  91.             expect(() => fs.lookForProducer('The')).to.throw(`The do not exist yet, but we need the money...`);
  92.         });
  93.     });
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement