Liliana797979

christmas movies - js advanced exam

Nov 26th, 2021
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('tests at ChristamsMovie class', function () {
  2.   let cm;
  3.   this.beforeEach(function () {
  4.     cm = new ChristmasMovies();
  5.   });
  6.   describe('tests all initial properties', function () {
  7.     //test 1
  8.     it('Instantiation with no parameters', function () {
  9.       expect(cm.movieCollection).to.eql([]);
  10.       expect(cm.movieCollection.length).to.deep.equal(0);
  11.       expect(cm.watched).to.eql({});
  12.       expect(cm.actors).to.deep.equal([]);
  13.       expect(cm.actors.length).to.deep.equal(0);
  14.     });
  15.   });
  16.  
  17.   describe('tests function buyMovie', function () {
  18.     // test 2
  19.     it('should return added corectly a movie', function () {
  20.       expect(
  21.         cm.buyMovie('Last Christmas', [
  22.           'Madison Ingoldsby',
  23.           'Emma Thompson',
  24.           'Boris Isakovic',
  25.           'Madison Ingoldsby',
  26.         ])
  27.       ).to.equal(
  28.         'You just got Last Christmas to your collection in which Madison Ingoldsby, Emma Thompson, Boris Isakovic are taking part!'
  29.       );
  30.     });
  31.  
  32.     it('should thrown error that exist a movie name', function () {
  33.       cm.buyMovie('Last Christmas', [
  34.         'Madison Ingoldsby',
  35.         'Emma Thompson',
  36.         'Boris Isakovic',
  37.         'Madison Ingoldsby',
  38.       ]);
  39.       expect(() =>
  40.         cm.buyMovie('Last Christmas', [
  41.           'Madison Ingoldsby',
  42.           'Emma Thompson',
  43.           'Boris Isakovic',
  44.           'Madison Ingoldsby',
  45.         ])
  46.       ).to.throw(Error, 'You already own Last Christmas in your collection!');
  47.     });
  48.   });
  49.  
  50.   describe('tests function discardMovie', function () {
  51.     it('should throw error that no exist movie name', function () {
  52.       expect(() => cm.discardMovie('The Grunch')).to.throw(
  53.         Error,
  54.         'The Grunch is not at your collection!'
  55.       );
  56.     });
  57.  
  58.     it('should throw error that no exist movie watch', function () {
  59.       cm.buyMovie('Last Christmas', [
  60.         'Madison Ingoldsby',
  61.         'Emma Thompson',
  62.         'Boris Isakovic',
  63.         'Madison Ingoldsby',
  64.       ]);
  65.       expect(() => cm.discardMovie('Last Christmas')).to.throw(
  66.         Error,
  67.         'Last Christmas is not watched!'
  68.       );
  69.     });
  70.  
  71.     it('should return message that correctly remove a movie', function () {
  72.       cm.buyMovie('Last Christmas', [
  73.         'Madison Ingoldsby',
  74.         'Emma Thompson',
  75.         'Boris Isakovic',
  76.         'Madison Ingoldsby',
  77.       ]);
  78.       cm.watchMovie('Last Christmas');
  79.       expect(cm.discardMovie('Last Christmas')).to.equal(
  80.         'You just threw away Last Christmas!'
  81.       );
  82.     });
  83.   });
  84.  
  85.   describe('tests function watchMovie', function () {
  86.     it('should throw error that no exist in collection list this a movie name', function () {
  87.       expect(() => cm.watchMovie('The Grunch')).to.throw(
  88.         Error,
  89.         'No such movie in your collection!'
  90.       );
  91.     });
  92.  
  93.     it('should return three watched a movie', function () {
  94.       cm.buyMovie('Last Christmas', [
  95.         'Madison Ingoldsby',
  96.         'Emma Thompson',
  97.         'Boris Isakovic',
  98.         'Madison Ingoldsby',
  99.       ]);
  100.       cm.watchMovie('Last Christmas');
  101.       cm.watchMovie('Last Christmas');
  102.       cm.watchMovie('Last Christmas');
  103.       expect(cm.watched['Last Christmas']).to.deep.equal(3);
  104.     });
  105.   });
  106.  
  107.   describe('tests function favouriteMovie', function () {
  108.     it('should thtow error that empty watched collection', function () {
  109.       expect(() => cm.favouriteMovie()).to.throw(
  110.         Error,
  111.         'You have not watched a movie yet this year!'
  112.       );
  113.     });
  114.  
  115.     it('should return a movie with the most watched', function () {
  116.       cm.buyMovie('Last Christmas', [
  117.         'Madison Ingoldsby',
  118.         'Emma Thompson',
  119.         'Boris Isakovic',
  120.         'Madison Ingoldsby',
  121.       ]);
  122.       cm.buyMovie('Home Alone', [
  123.         'Macaulay Culkin',
  124.         'Joe Pesci',
  125.         'Daniel Stern',
  126.       ]);
  127.       cm.watchMovie('Last Christmas');
  128.       cm.watchMovie('Last Christmas');
  129.       cm.watchMovie('Last Christmas');
  130.       cm.watchMovie('Home Alone');
  131.       expect(cm.favouriteMovie()).to.equal(
  132.         'Your favourite movie is Last Christmas and you have watched it 3 times!'
  133.       );
  134.     });
  135.   });
  136.  
  137.   describe('tests function mostStarredActors', function () {
  138.     //test 11
  139.     it('should throw error that empty movieCollection', function () {
  140.       expect(() => cm.mostStarredActor()).to.throw(
  141.         Error,
  142.         'You have not watched a movie yet this year!'
  143.       );
  144.     });
  145.     //test 10
  146.     it('should return the most played actor  in the movies', function () {
  147.       cm.buyMovie('Home Alone', [
  148.         'Macaulay Culkin',
  149.         'Joe Pesci',
  150.         'Daniel Stern',
  151.       ]);
  152.       cm.buyMovie('Last Christmas', [
  153.         'Madison Ingoldsby',
  154.         'Emma Thompson',
  155.         'Boris Isakovic',
  156.         'Madison Ingoldsby',
  157.       ]);
  158.       cm.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  159.       cm.buyMovie('Home Alone 3', ['Macaulay Culkin', 'Emma Thompson']);
  160.       cm.watchMovie('Home Alone');
  161.       expect(cm.mostStarredActor()).to.equal(
  162.         'The most starred actor is Macaulay Culkin and starred in 3 movies!'
  163.       );
  164.     });
  165.   });
  166.  
  167.     });
  168.  
  169.  
Advertisement
Add Comment
Please, Sign In to add comment