Advertisement
Liliana797979

Christmas movies - js advanced exam

Oct 22nd, 2021
206
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(cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']))
  21.             .to.equal('You just got Last Christmas to your collection in which Madison Ingoldsby, Emma Thompson, Boris Isakovic are taking part!');
  22.         });
  23.  
  24.         it('should thrown error that exist a movie name', function() {
  25.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  26.             expect(() => cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']))
  27.             .to.throw(Error, 'You already own Last Christmas in your collection!');
  28.         });
  29.     });
  30.  
  31.     describe('tests function discardMovie', function() {
  32.         it('should throw error that no exist movie name', function() {
  33.             expect(() => cm.discardMovie('The Grunch')).to.throw(Error, 'The Grunch is not at your collection!');
  34.         });
  35.  
  36.         it('should throw error that no exist movie watch', function() {
  37.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  38.             expect(() => cm.discardMovie('Last Christmas')).to.throw(Error, 'Last Christmas is not watched!');
  39.         });
  40.  
  41.         it('should return message that correctly remove a movie', function() {
  42.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  43.             cm.watchMovie('Last Christmas');
  44.             expect(cm.discardMovie('Last Christmas')).to.equal('You just threw away Last Christmas!');
  45.         });
  46.     });
  47.  
  48.     describe('tests function watchMovie', function() {
  49.         it('should throw error that no exist in collection list this a movie name', function() {
  50.             expect(()=> cm.watchMovie('The Grunch')).to.throw(Error, 'No such movie in your collection!');
  51.         });
  52.  
  53.         it('should return three watched a movie', function() {
  54.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  55.             cm.watchMovie('Last Christmas');
  56.             cm.watchMovie('Last Christmas');
  57.             cm.watchMovie('Last Christmas');
  58.             expect(cm.watched['Last Christmas']).to.deep.equal(3);
  59.         });
  60.     });
  61.  
  62.     describe('tests function favouriteMovie', function() {
  63.         it('should thtow error that empty watched collection', function() {
  64.             expect(() => cm.favouriteMovie()).to.throw(Error, 'You have not watched a movie yet this year!');
  65.         });
  66.  
  67.         it('should return a movie with the most watched', function() {
  68.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  69.             cm.buyMovie('Home Alone', ['Macaulay Culkin', 'Joe Pesci', 'Daniel Stern']);
  70.             cm.watchMovie('Last Christmas');
  71.             cm.watchMovie('Last Christmas');
  72.             cm.watchMovie('Last Christmas');
  73.             cm.watchMovie('Home Alone');
  74.             expect(cm.favouriteMovie()).to.equal('Your favourite movie is Last Christmas and you have watched it 3 times!');
  75.         });
  76.     });
  77.  
  78.     describe('tests function mostStarredActors', function() {
  79.         //test 11
  80.         it('should throw error that empty movieCollection', function() {
  81.             expect(() => cm.mostStarredActor()).to.throw(Error, 'You have not watched a movie yet this year!');
  82.         });
  83.         //test 10
  84.         it('should return the most played actor  in the movies', function() {
  85.             cm.buyMovie('Home Alone', ['Macaulay Culkin', 'Joe Pesci', 'Daniel Stern']);
  86.             cm.buyMovie('Last Christmas', ['Madison Ingoldsby', 'Emma Thompson', 'Boris Isakovic', 'Madison Ingoldsby']);
  87.             cm.buyMovie('Home Alone 2', ['Macaulay Culkin']);
  88.             cm.buyMovie('Home Alone 3', ['Macaulay Culkin', 'Emma Thompson']);
  89.             cm.watchMovie('Home Alone');
  90.             expect(cm.mostStarredActor()).to.equal('The most starred actor is Macaulay Culkin and starred in 3 movies!');
  91.  
  92.         });
  93.     });
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement