Advertisement
viligen

christmasMovies

Jun 23rd, 2022
717
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('Tests cm', function () {
  2.     let christmas;
  3.     beforeEach(() => {
  4.         christmas = new ChristmasMovies();
  5.     });
  6.     describe('constructor ', function () {
  7.         it('assert with valid params', () => {
  8.             assert.deepEqual(christmas.movieCollection, []);
  9.             assert.deepEqual(christmas.watched, {});
  10.             assert.deepEqual(christmas.actors, []);
  11.             assert.deepEqual(christmas.actors.length, 0);
  12.             assert.deepEqual(christmas.movieCollection.length, 0);
  13.         });
  14.     });
  15.     describe('method 1 ', function () {
  16.         it('assert with valid params', () => {
  17.             assert.equal(
  18.                 christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']),
  19.                 'You just got Home Alone 2 to your collection in which Macaulay Culkin are taking part!'
  20.             );
  21.             // assert.isTrue(christmas.movieCollection.length === 1);
  22.             assert.equal(
  23.                 christmas.buyMovie('Last Christmas', [
  24.                     'Emilia Clarke',
  25.                     'Henry Golding',
  26.                     'Emilia Clarke',
  27.                 ]),
  28.                 'You just got Last Christmas to your collection in which Emilia Clarke, Henry Golding are taking part!'
  29.             );
  30.             // assert.isTrue(christmas.movieCollection.length === 2);
  31.             // assert.isTrue(christmas.actors.length === 0);
  32.             assert.equal(
  33.                 christmas.buyMovie('The Grinch', [
  34.                     'Benedict Cumberbatch',
  35.                     'Pharrell Williams',
  36.                 ]),
  37.                 'You just got The Grinch to your collection in which Benedict Cumberbatch, Pharrell Williams are taking part!'
  38.             );
  39.             assert.Throw(
  40.                 () =>
  41.                     christmas.buyMovie('The Grinch', [
  42.                         'Benedict Cumberbatch',
  43.                         'Pharrell Williams',
  44.                     ]),
  45.                 'You already own The Grinch in your collection!'
  46.             );
  47.         });
  48.  
  49.         it('assert with invalid params', () => {
  50.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  51.             christmas.buyMovie('Last Christmas', [
  52.                 'Emilia Clarke',
  53.                 'Henry Golding',
  54.             ]);
  55.             assert.Throw(
  56.                 () => christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']),
  57.                 'You already own Home Alone 2 in your collection!'
  58.             );
  59.  
  60.             assert.Throw(
  61.                 () =>
  62.                     christmas.buyMovie('Last Christmas', [
  63.                         'Emilia Clarke',
  64.                         'Henry Golding',
  65.                     ]),
  66.                 'You already own Last Christmas in your collection!'
  67.             );
  68.         });
  69.     });
  70.     describe('method 2 ', function () {
  71.         it('assert with valid params', () => {
  72.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  73.             christmas.watchMovie('Home Alone 2');
  74.             assert.equal(
  75.                 christmas.discardMovie('Home Alone 2'),
  76.                 'You just threw away Home Alone 2!'
  77.             );
  78.             assert.equal(Object.keys(christmas.watched).length, 0);
  79.         });
  80.  
  81.         it('assert with invalid params', () => {
  82.             assert.Throw(
  83.                 () => christmas.discardMovie('Home Alone 2'),
  84.                 'Home Alone 2 is not at your collection!'
  85.             );
  86.  
  87.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  88.  
  89.             assert.Throw(
  90.                 () => christmas.discardMovie('Home Alone 2'),
  91.                 'Home Alone 2 is not watched!'
  92.             );
  93.         });
  94.     });
  95.     describe('method 3 ', function () {
  96.         it('assert with valid params', () => {
  97.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  98.             christmas.watchMovie('Home Alone 2');
  99.             assert.equal(Object.keys(christmas.watched).length, 1);
  100.             assert.equal(christmas.watched['Home Alone 2'], 1);
  101.             christmas.watchMovie('Home Alone 2');
  102.             assert.equal(Object.keys(christmas.watched).length, 1);
  103.             assert.equal(christmas.watched['Home Alone 2'], 2);
  104.             christmas.watchMovie('Home Alone 2');
  105.             assert.equal(christmas.watched['Home Alone 2'], 3);
  106.         });
  107.  
  108.         it('assert with invalid params', () => {
  109.             assert.throw(
  110.                 () => christmas.watchMovie('Home Alone 2'),
  111.                 'No such movie in your collection!'
  112.             );
  113.         });
  114.     });
  115.     describe('method 4 ', function () {
  116.         it('assert with valid params', () => {
  117.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  118.             christmas.buyMovie('Last Christmas', [
  119.                 'Emilia Clarke',
  120.                 'Henry Golding',
  121.             ]);
  122.             christmas.buyMovie('The Grinch', [
  123.                 'Benedict Cumberbatch',
  124.                 'Pharrell Williams',
  125.             ]);
  126.             christmas.watchMovie('Home Alone 2');
  127.  
  128.             assert.equal(
  129.                 christmas.favouriteMovie(),
  130.                 'Your favourite movie is Home Alone 2 and you have watched it 1 times!'
  131.             );
  132.             christmas.watchMovie('The Grinch');
  133.             christmas.watchMovie('Last Christmas');
  134.             christmas.watchMovie('Home Alone 2');
  135.             christmas.watchMovie('Home Alone 2');
  136.             christmas.watchMovie('Last Christmas');
  137.             assert.equal(
  138.                 christmas.favouriteMovie(),
  139.                 'Your favourite movie is Home Alone 2 and you have watched it 3 times!'
  140.             );
  141.             christmas.discardMovie('Home Alone 2');
  142.             assert.equal(
  143.                 christmas.favouriteMovie(),
  144.                 'Your favourite movie is Last Christmas and you have watched it 2 times!'
  145.             );
  146.         });
  147.  
  148.         it('assert with invalid params', () => {
  149.             christmas.buyMovie('The Grinch', [
  150.                 'Benedict Cumberbatch',
  151.                 'Pharrell Williams',
  152.             ]);
  153.             assert.Throw(
  154.                 () => christmas.favouriteMovie(),
  155.                 'You have not watched a movie yet this year!'
  156.             );
  157.         });
  158.     });
  159.     describe('method 5 ', function () {
  160.         it('assert with valid params', () => {
  161.             christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  162.             christmas.buyMovie('Home Alone', [
  163.                 'Macaulay Culkin',
  164.                 'Emilia Clarke',
  165.             ]);
  166.             christmas.buyMovie('Home Alone 3', [
  167.                 'Macaulay Culkin',
  168.                 'Emilia Clarke',
  169.             ]);
  170.             christmas.buyMovie('Last Christmas', [
  171.                 'Emilia Clarke',
  172.                 'Henry Golding',
  173.             ]);
  174.             christmas.buyMovie('The Grinch', [
  175.                 'Benedict Cumberbatch',
  176.                 'Pharrell Williams',
  177.             ]);
  178.             assert.equal(
  179.                 christmas.mostStarredActor(),
  180.                 'The most starred actor is Macaulay Culkin and starred in 3 movies!'
  181.             );
  182.             christmas.watchMovie('Home Alone 2');
  183.             christmas.discardMovie('Home Alone 2');
  184.             assert.equal(
  185.                 christmas.mostStarredActor(),
  186.                 'The most starred actor is Emilia Clarke and starred in 3 movies!'
  187.             );
  188.         });
  189.  
  190.         it('assert with invalid params', () => {
  191.             assert.Throw(
  192.                 () => christmas.mostStarredActor(),
  193.                 'You have not watched a movie yet this year!'
  194.             );
  195.         });
  196.     });
  197. });
Advertisement
RAW Paste Data Copied
Advertisement