Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe("HolidayPackage Test", function() {
- let sampleInstance;
- beforeEach(function(){
- sampleInstance = new HolidayPackage("Hawaii","Winter");
- });
- it('testing constructor destiantion property', function() {
- expect(sampleInstance.destination).to.deep.equal('Hawaii');
- });
- it('testing constructor season property', function() {
- expect(sampleInstance.season).to.deep.equal('Winter');
- });
- it('testing constructor insuranceIncluded property', function() {
- expect(sampleInstance.insuranceIncluded).to.deep.equal(false);
- });
- it('testing constructor vacationers property', function() {
- expect(sampleInstance.vacationers).to.deep.equal([]);
- });
- it('testing addVacationer', function() {
- expect(()=>sampleInstance.addVacationer(' ')).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing addVacationer with NO string', function() {
- expect(()=>sampleInstance.addVacationer(123123)).to.throw('Vacationer name must be a non-empty string');
- });
- it('testing addVacationer to include first and last name', function() {
- expect(()=>sampleInstance.addVacationer('Ivailo')).to.throw('Name must consist of first name and last name');
- });
- it('testing insuranceIncluded with NON boolean', function() {
- expect(()=> sampleInstance.insuranceIncluded = "Pesho").to.throw('Insurance status must be a boolean');
- });
- it('testing insuranceIncluded with TRUE boolean', function() {
- sampleInstance.insuranceIncluded = true;
- expect( sampleInstance.insuranceIncluded ).to.equal(true);
- });
- it('testing insuranceIncluded with FALSE boolean', function() {
- sampleInstance.insuranceIncluded = false;
- expect( sampleInstance.insuranceIncluded ).to.equal(false);
- });
- it('testing generateHolidayPackage without people', function() {
- expect(()=> sampleInstance.generateHolidayPackage()).to.throw('There must be at least 1 vacationer added');
- });
- it('testing generateHolidayPackage', function() {
- sampleInstance.addVacationer('Pesho Peshov');
- expect(sampleInstance.generateHolidayPackage()).to.equal(`Holiday Package Generated\nDestination: Hawaii\nVacationers:\nPesho Peshov\nPrice: 600`);
- });
- it('testing generateHolidayPackage with wrong season', function() {
- sampleInstance = new HolidayPackage('Hawaii','ASDASD')
- sampleInstance.addVacationer('Pesho Peshov');
- sampleInstance.addVacationer('Gosho Peshov');
- expect(sampleInstance.generateHolidayPackage()).to.equal(`Holiday Package Generated\nDestination: Hawaii\nVacationers:\nPesho Peshov\nGosho Peshov\nPrice: 800`);
- });
- it('testing showVacationers without people', function() {
- expect(sampleInstance.showVacationers()).to.deep.equal("No vacationers are added yet");
- });
- it('testing showVacationers with two people', function() {
- sampleInstance.addVacationer('Pesho Peshov');
- sampleInstance.addVacationer('Gosho Peshov');
- expect(sampleInstance.showVacationers()).to.deep.equal(`Vacationers:\nPesho Peshov\nGosho Peshov`);
- });
- it('testing generateHolidayPackage with insurance', function() {
- sampleInstance.addVacationer('Pesho Peshov');
- sampleInstance.addVacationer('Gosho Peshov');
- sampleInstance.insuranceIncluded = true;
- expect(sampleInstance.generateHolidayPackage()).to.equal(`Holiday Package Generated\nDestination: Hawaii\nVacationers:\nPesho Peshov\nGosho Peshov\nPrice: 1100`);
- });
- it('testing generateHolidayPackage with insurance and summer', function() {
- sampleInstance = new HolidayPackage('Hawaii','Summer')
- sampleInstance.addVacationer('Pesho Peshov');
- sampleInstance.addVacationer('Gosho Peshov');
- sampleInstance.insuranceIncluded = true;
- expect(sampleInstance.generateHolidayPackage()).to.equal(`Holiday Package Generated\nDestination: Hawaii\nVacationers:\nPesho Peshov\nGosho Peshov\nPrice: 1100`);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement