emotrend

Untitled

Mar 13th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let HolidayPackage = require('./HolidayPackage');
  2. let expect = require('chai').expect;
  3.  
  4. //90points
  5. describe('testing HolidayPackage', function() {
  6.     let holiday;
  7.     beforeEach(function() {
  8.         holiday = new HolidayPackage('slunchev briag', 'bg');
  9.     });
  10.  
  11.     describe('testing constructor', function() {
  12.    
  13.         it('testing constructor destiantion property', function() {
  14.             expect(holiday.destination).to.deep.equal('slunchev briag');
  15.         });
  16.  
  17.         it('testing constructor season property', function() {
  18.             expect(holiday.season).to.deep.equal('bg');
  19.         });
  20.  
  21.         it('testing constructor season property', function() {
  22.             expect(holiday.vacationers).to.deep.equal([]);
  23.         });
  24.  
  25.         it('testing first parameter', function() {
  26.             let holidayConst = new HolidayPackage('dest', 2);
  27.             expect(typeof holidayConst.destination).to.equal('string')
  28.         });
  29.         it('testing second parameter', function() {
  30.             let holidayConst = new HolidayPackage(true, 'str');
  31.             expect(typeof holidayConst.season).to.equal('string');
  32.         });
  33.  
  34.         it('testing insuranceIncluded', function() {
  35.             expect(holiday.insuranceIncluded).to.equal(false);
  36.         });
  37.         it('testing insuranceIncluded', function() {
  38.             holiday.insuranceIncluded = true;
  39.             expect(holiday.insuranceIncluded).to.equal(true);
  40.         });
  41.     });
  42.  
  43.     describe('testing addVacationer', function() {
  44.         it('testing with wrong parameters', function() {
  45.             expect(() => holiday.addVacationer(1)).to.throw('Vacationer name must be a non-empty string');
  46.         });
  47.         it('testing with wrong parameters', function() {
  48.             expect(() => holiday.addVacationer(true)).to.throw('Vacationer name must be a non-empty string');
  49.         });
  50.         it('testing with wrong parameters', function() {
  51.             expect(() => holiday.addVacationer(1.3)).to.throw('Vacationer name must be a non-empty string');
  52.         });
  53.         it('testing with wrong parameters', function() {
  54.             expect(() => holiday.addVacationer({})).to.throw('Vacationer name must be a non-empty string');
  55.         });
  56.         it('testing with wrong parameters', function() {
  57.             expect(() => holiday.addVacationer([])).to.throw('Vacationer name must be a non-empty string');
  58.         });
  59.         it('testing with wrong parameters', function() {
  60.             expect(() => holiday.addVacationer('')).to.throw('Vacationer name must be a non-empty string');
  61.         });
  62.  
  63.  
  64.         it('testing with one or more than two names', function() {
  65.             expect(() => holiday.addVacationer('pesho gosho maria')).to.throw('Name must consist of first name and last name');
  66.         });
  67.         it('testing with one or more than two names', function() {
  68.             expect(() => holiday.addVacationer('pesho')).to.throw('Name must consist of first name and last name');
  69.         });
  70.         it('testing with one or more than two names', function() {
  71.             expect(() => holiday.insuranceIncluded = 'pesho').to.throw('Insurance status must be a boolean');
  72.         });
  73.  
  74.         it('should be true', function() {
  75.             expect(() => holiday.addVacationer('pesho mariikov')).to.not.throw();
  76.         });
  77.     });
  78.  
  79.     describe('testing showVacationers', function() {
  80.         it('testing with valid input', function() {
  81.             holiday.addVacationer('pesho minkov');
  82.             holiday.addVacationer('gosho minkov');
  83.             expect(holiday.showVacationers()).to.equal('Vacationers:\npesho minkov\ngosho minkov')
  84.         });
  85.         it('testing with no items', function() {
  86.             expect(holiday.showVacationers()).to.deep.equal('No vacationers are added yet');
  87.         });
  88.     });
  89.  
  90.     describe('testing generateHolidayPackage', function() {
  91.         it('testing with el less than 1', function() {
  92.             expect(() => holiday.generateHolidayPackage()).to.throw('There must be at least 1 vacationer added');
  93.         });
  94.         it('testing with valid params', function() {
  95.             holiday.addVacationer('pesho peshov');
  96.             holiday.addVacationer('gosho goshov');
  97.             holiday.addVacationer('ivan ivanov');
  98.  
  99.             expect(holiday.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: slunchev briag\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1200');
  100.         });
  101.         it('testing with valid params and insurance', function() {
  102.             holiday.addVacationer('pesho peshov');
  103.             holiday.addVacationer('gosho goshov');
  104.             holiday.addVacationer('ivan ivanov');
  105.             holiday.insuranceIncluded = true;
  106.             expect(holiday.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: slunchev briag\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1300');
  107.         });
  108.         it('testing with summer', function() {
  109.             let summer = new HolidayPackage('pirin', 'Summer');
  110.             summer.addVacationer('pesho peshov');
  111.             summer.addVacationer('gosho goshov');
  112.             summer.addVacationer('ivan ivanov');
  113.             expect(summer.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1400');
  114.         });
  115.         it('testing with summer and insurance', function() {
  116.             let summer = new HolidayPackage('pirin', 'Summer');
  117.             summer.addVacationer('pesho peshov');
  118.             summer.addVacationer('gosho goshov');
  119.             summer.addVacationer('ivan ivanov');
  120.             summer.insuranceIncluded = true;
  121.             expect(summer.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1500');
  122.         });
  123.         it('testing with summer', function() {
  124.             let winter = new HolidayPackage('pirin', 'Winter');
  125.             winter.addVacationer('pesho peshov');
  126.             winter.addVacationer('gosho goshov');
  127.             winter.addVacationer('ivan ivanov');
  128.             winter.addVacationer('ivan ivanov');
  129.             winter.addVacationer('ivan ivanov');
  130.             expect(winter.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nivan ivanov\nivan ivanov\nPrice: 2200');
  131.         });
  132.         it('testing with summer and insurance', function() {
  133.             let winter = new HolidayPackage('pirin', 'Winter');
  134.             winter.addVacationer('pesho peshov');
  135.             winter.addVacationer('gosho goshov');
  136.             winter.addVacationer('ivan ivanov');
  137.             winter.addVacationer('ivan ivanov');
  138.             winter.addVacationer('ivan ivanov');
  139.             winter.insuranceIncluded = true;
  140.             expect(winter.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nivan ivanov\nivan ivanov\nPrice: 2300');
  141.         });
  142.     });
  143. });
Advertisement
Add Comment
Please, Sign In to add comment