Liliana797979

04. Math enforcer - js advansed

Feb 20th, 2022
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. describe('mathEnforcer', () => {
  4.     describe('addFive', () => {
  5.         it('Should return undefined when parameter is not a number', () => {
  6.             expect(mathEnforcer.addFive(undefined)).to.equal(undefined);
  7.             expect(mathEnforcer.addFive(null)).to.equal(undefined);
  8.             expect(mathEnforcer.addFive('20')).to.equal(undefined);
  9.         })
  10.  
  11.         it('Should return number plus 5 when parameter is valid number', () => {
  12.             expect(mathEnforcer.addFive(10)).to.equal(15);
  13.             expect(mathEnforcer.addFive(1.1 + 2.2)).to.closeTo(8.3, 0.01);
  14.             expect(mathEnforcer.addFive(-10)).to.equal(-5);
  15.         })
  16.     })
  17.  
  18.     describe('subtractTen', () => {
  19.         it('Should return undefined when parameter is not a number', () => {
  20.             expect(mathEnforcer.subtractTen(undefined)).to.equal(undefined);
  21.             expect(mathEnforcer.subtractTen(null)).to.equal(undefined);
  22.             expect(mathEnforcer.subtractTen('20')).to.equal(undefined);
  23.         })
  24.  
  25.         it('Should return number plus 5 when parameter is valid number', () => {
  26.             expect(mathEnforcer.subtractTen(10)).to.equal(0);
  27.             expect(mathEnforcer.subtractTen(1.1 + 2.2)).to.closeTo(-6.7, 0.01);
  28.             expect(mathEnforcer.subtractTen(-10)).to.equal(-20);
  29.         })
  30.     })
  31.  
  32.     describe('sum', () => {
  33.         it('Should return undefined when first parameter is not a number', () => {
  34.             expect(mathEnforcer.sum(undefined, 1)).to.equal(undefined);
  35.             expect(mathEnforcer.sum(null, 1)).to.equal(undefined);
  36.             expect(mathEnforcer.sum('13', 1)).to.equal(undefined);
  37.         })
  38.  
  39.         it('Should return undefined when second parameter is not a number', () => {
  40.             expect(mathEnforcer.sum(1, undefined)).to.equal(undefined);
  41.             expect(mathEnforcer.sum(1, null)).to.equal(undefined);
  42.             expect(mathEnforcer.sum(1, '13')).to.equal(undefined);
  43.         })
  44.  
  45.         it('Should return the sum of both numbers when both parameter are valid numbers', () => {
  46.             expect(mathEnforcer.sum(10, 20)).to.equal(30);
  47.             expect(mathEnforcer.sum(1.1 + 2.2, 3.3)).to.closeTo(6.6, 0.01);
  48.             expect(mathEnforcer.sum(-10, -5)).to.equal(-15);
  49.         })
  50.     })
  51. })
Advertisement
Add Comment
Please, Sign In to add comment