georgiev955

Demo unit testing

Oct 3rd, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('Motorcycle Rider', () => {
  2.     it('licenseRestriction', () => {
  3.         expect(motorcycleRider.licenseRestriction('AM')).to.equal('Mopeds with a maximum design speed of 45 km. per hour, engine volume is no more than 50 cubic centimeters, and the minimum age is 16.');
  4.         expect(motorcycleRider.licenseRestriction('A1')).to.equal('Motorcycles with engine volume is no more than 125 cubic centimeters, maximum power of 11KW. and the minimum age is 16.');
  5.         expect(motorcycleRider.licenseRestriction('A2')).to.equal('Motorcycles with maximum power of 35KW. and the minimum age is 18.');
  6.         expect(motorcycleRider.licenseRestriction('A')).to.equal('No motorcycle restrictions, and the minimum age is 24.');
  7.         expect(() => { motorcycleRider.licenseRestriction('Z') }).to.throw('Invalid Information!');
  8.         expect(() => { motorcycleRider.licenseRestriction(5) }).to.throw('Invalid Information!');
  9.     });
  10.  
  11.     it('motorcycleShowroom', () => {
  12.         expect(() => { motorcycleRider.motorcycleShowroom('300', 350) }).to.throw('Invalid Information!');
  13.         expect(() => { motorcycleRider.motorcycleShowroom(['300', '500'], 'fifty') }).to.throw('Invalid Information!');
  14.         expect(() => { motorcycleRider.motorcycleShowroom(['300', '500'], '5') }).to.throw('Invalid Information!');
  15.         expect(() => { motorcycleRider.motorcycleShowroom([], 600) }).to.throw('Invalid Information!');
  16.         expect(() => { motorcycleRider.motorcycleShowroom(['300'], -1) }).to.throw('Invalid Information!');
  17.         expect(() => { motorcycleRider.motorcycleShowroom(['300'], 49) }).to.throw('Invalid Information!');
  18.         expect(motorcycleRider.motorcycleShowroom(['50'], 50)).to.equal('There are 1 available motorcycles matching your criteria!');
  19.         expect(motorcycleRider.motorcycleShowroom([300, 250, 400, 550, "five", -6], 600)).to.equal('There are 4 available motorcycles matching your criteria!');
  20.         expect(motorcycleRider.motorcycleShowroom([300, 40, 20, 50, "five", -6], 600)).to.equal('There are 2 available motorcycles matching your criteria!');
  21.         expect(motorcycleRider.motorcycleShowroom(['300', '250', '400', '550', 'fifty', '-1000',], 600)).to.equal('There are 4 available motorcycles matching your criteria!');
  22.         expect(motorcycleRider.motorcycleShowroom([0], 600)).to.equal('There are 0 available motorcycles matching your criteria!');
  23.     });
  24.  
  25.     it('otherSpendings', () => {
  26.         expect(() => { motorcycleRider.otherSpendings(['helmet', 'jacked'], 'oil filter', true) }).to.throw('Invalid Information!');
  27.         expect(() => { motorcycleRider.otherSpendings('helmet', ['oil filter'], true) }).to.throw('Invalid Information!');
  28.         expect(() => { motorcycleRider.otherSpendings(['helmet', 'jacked'], 'oil filter', true) }).to.throw('Invalid Information!');
  29.         expect(motorcycleRider.otherSpendings(['helmet', 'jacked'], [], true)).to.equal('You spend $450.00 for equipment and consumables with 10% discount!');
  30.         expect(motorcycleRider.otherSpendings(['helmet', 'jacked'], [], false)).to.equal('You spend $500.00 for equipment and consumables!');
  31.         expect(motorcycleRider.otherSpendings(['helmet'], ['engine oil'], true)).to.equal('You spend $243.00 for equipment and consumables with 10% discount!');
  32.         expect(motorcycleRider.otherSpendings([], ['engine oil', 'oil filter'], false)).to.equal('You spend $100.00 for equipment and consumables!');
  33.         expect(motorcycleRider.otherSpendings([], ['engine oil', 'oil filter'], true)).to.equal('You spend $90.00 for equipment and consumables with 10% discount!');
  34.  
  35.     });
  36.  
  37. });
Advertisement
Add Comment
Please, Sign In to add comment