Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let expect = require('chai').expect;
- let HolidayPackage = require('../sourcecode').HolidayPackage;
- describe("Holiday Package", function() {
- let holidayPackage;
- beforeEach(function () {
- holidayPackage = new HolidayPackage('Mallorca', 'Summer');
- });
- describe("init", function() {
- it("should generate corectly", function() {
- expect(holidayPackage.destination).equal('Mallorca');
- expect(holidayPackage.season).equal('Summer');
- expect(holidayPackage.showVacationers()).equal('No vacationers are added yet');
- expect(holidayPackage.vacationers).eql([]);
- expect(holidayPackage.insuranceIncluded ).equal(false);
- });
- });
- describe("init without params", function() {
- let holidayPackage1 = new HolidayPackage();
- it("should generate corectly without params", function() {
- expect(holidayPackage1.destination).equal(undefined);
- expect(holidayPackage1.season).equal(undefined);
- });
- });
- describe("insurance", function() {
- it("should set insurance corectly", function() {
- holidayPackage.insuranceIncluded = true;
- expect(holidayPackage.insuranceIncluded ).equal(true);
- });
- it("should throw if insurance value is not boolean", function() {
- expect(() => {holidayPackage.insuranceIncluded='Pesho'}).throw("Insurance status must be a boolean");
- });
- });
- describe("vacationers", function() {
- it("should show vacationers corectly", function() {
- expect(holidayPackage.showVacationers()).equal("No vacationers are added yet");
- });
- it("should add and show vacationers corectly", function() {
- holidayPackage.addVacationer('Danny Berova');
- holidayPackage.addVacationer('Nicky Berov');
- expect(holidayPackage.showVacationers()).equal('Vacationers:\nDanny Berova\nNicky Berov');
- });
- it("should throw for split", function() {
- expect(() => {holidayPackage.addVacationer('Danny')}).throw("Name must consist of first name and last name");
- });
- it("should throw if empty", function() {
- expect(() => {holidayPackage.addVacationer()}).throw("Vacationer name must be a non-empty string");
- });
- it("should throw if empty string", function() {
- expect(() => {holidayPackage.addVacationer(' ')}).throw("Vacationer name must be a non-empty string");
- });
- it("should throw if non-string", function() {
- expect(() => {holidayPackage.addVacationer(5)}).throw("Vacationer name must be a non-empty string");
- });
- });
- describe("generate HolydayPackage corectly", function() {
- it("should generate corectly", function() {
- holidayPackage.addVacationer('Danny Berova');
- holidayPackage.addVacationer('Nicky Berov');
- expect(holidayPackage.generateHolidayPackage())
- .equal("Holiday Package Generated\n" +
- "Destination: " + 'Mallorca' + "\n" +
- 'Vacationers:\nDanny Berova\nNicky Berov' + "\n" +
- "Price: " + '1000');
- });
- it("should generate corectly with insurance", function() {
- holidayPackage.addVacationer('Danny Berova');
- holidayPackage.addVacationer('Nicky Berov');
- holidayPackage.insuranceIncluded = true;
- expect(holidayPackage.generateHolidayPackage())
- .equal("Holiday Package Generated\n" +
- "Destination: " + 'Mallorca' + "\n" +
- 'Vacationers:\nDanny Berova\nNicky Berov' + "\n" +
- "Price: " + '1100');
- });
- it("should throw without vacationers", function() {
- expect(() => {holidayPackage.generateHolidayPackage()}).throw();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement