Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let HolidayPackage = require('./HolidayPackage');
- let expect = require('chai').expect;
- //90points
- describe('testing HolidayPackage', function() {
- let holiday;
- beforeEach(function() {
- holiday = new HolidayPackage('slunchev briag', 'bg');
- });
- describe('testing constructor', function() {
- it('testing constructor destiantion property', function() {
- expect(holiday.destination).to.deep.equal('slunchev briag');
- });
- it('testing constructor season property', function() {
- expect(holiday.season).to.deep.equal('bg');
- });
- it('testing constructor season property', function() {
- expect(holiday.vacationers).to.deep.equal([]);
- });
- it('testing first parameter', function() {
- let holidayConst = new HolidayPackage('dest', 2);
- expect(typeof holidayConst.destination).to.equal('string')
- });
- it('testing second parameter', function() {
- let holidayConst = new HolidayPackage(true, 'str');
- expect(typeof holidayConst.season).to.equal('string');
- });
- it('testing insuranceIncluded', function() {
- expect(holiday.insuranceIncluded).to.equal(false);
- });
- it('testing insuranceIncluded', function() {
- holiday.insuranceIncluded = true;
- expect(holiday.insuranceIncluded).to.equal(true);
- });
- });
- describe('testing addVacationer', function() {
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer(1)).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer(true)).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer(1.3)).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer({})).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer([])).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with wrong parameters', function() {
- expect(() => holiday.addVacationer('')).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing with one or more than two names', function() {
- expect(() => holiday.addVacationer('pesho gosho maria')).to.throw('Name must consist of first name and last name');
- });
- it('testing with one or more than two names', function() {
- expect(() => holiday.addVacationer('pesho')).to.throw('Name must consist of first name and last name');
- });
- it('testing with one or more than two names', function() {
- expect(() => holiday.insuranceIncluded = 'pesho').to.throw('Insurance status must be a boolean');
- });
- it('should be true', function() {
- expect(() => holiday.addVacationer('pesho mariikov')).to.not.throw();
- });
- });
- describe('testing showVacationers', function() {
- it('testing with valid input', function() {
- holiday.addVacationer('pesho minkov');
- holiday.addVacationer('gosho minkov');
- expect(holiday.showVacationers()).to.equal('Vacationers:\npesho minkov\ngosho minkov')
- });
- it('testing with no items', function() {
- expect(holiday.showVacationers()).to.deep.equal('No vacationers are added yet');
- });
- });
- describe('testing generateHolidayPackage', function() {
- it('testing with el less than 1', function() {
- expect(() => holiday.generateHolidayPackage()).to.throw('There must be at least 1 vacationer added');
- });
- it('testing with valid params', function() {
- holiday.addVacationer('pesho peshov');
- holiday.addVacationer('gosho goshov');
- holiday.addVacationer('ivan ivanov');
- expect(holiday.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: slunchev briag\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1200');
- });
- it('testing with valid params and insurance', function() {
- holiday.addVacationer('pesho peshov');
- holiday.addVacationer('gosho goshov');
- holiday.addVacationer('ivan ivanov');
- holiday.insuranceIncluded = true;
- expect(holiday.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: slunchev briag\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1300');
- });
- it('testing with summer', function() {
- let summer = new HolidayPackage('pirin', 'Summer');
- summer.addVacationer('pesho peshov');
- summer.addVacationer('gosho goshov');
- summer.addVacationer('ivan ivanov');
- expect(summer.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1400');
- });
- it('testing with summer and insurance', function() {
- let summer = new HolidayPackage('pirin', 'Summer');
- summer.addVacationer('pesho peshov');
- summer.addVacationer('gosho goshov');
- summer.addVacationer('ivan ivanov');
- summer.insuranceIncluded = true;
- expect(summer.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nPrice: 1500');
- });
- it('testing with summer', function() {
- let winter = new HolidayPackage('pirin', 'Winter');
- winter.addVacationer('pesho peshov');
- winter.addVacationer('gosho goshov');
- winter.addVacationer('ivan ivanov');
- winter.addVacationer('ivan ivanov');
- winter.addVacationer('ivan ivanov');
- expect(winter.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nivan ivanov\nivan ivanov\nPrice: 2200');
- });
- it('testing with summer and insurance', function() {
- let winter = new HolidayPackage('pirin', 'Winter');
- winter.addVacationer('pesho peshov');
- winter.addVacationer('gosho goshov');
- winter.addVacationer('ivan ivanov');
- winter.addVacationer('ivan ivanov');
- winter.addVacationer('ivan ivanov');
- winter.insuranceIncluded = true;
- expect(winter.generateHolidayPackage()).to.equal('Holiday Package Generated\nDestination: pirin\nVacationers:\npesho peshov\ngosho goshov\nivan ivanov\nivan ivanov\nivan ivanov\nPrice: 2300');
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment