Advertisement
Lulunga

Unit Testing 04. Math Enforcer

Oct 21st, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("mathEnforcer", function () {
  2.    describe('addFive', function () {
  3.       it("should return undefined for non-number parameter",function () {
  4.           expect(mathEnforcer.addFive("5")).to.be.equal(undefined);
  5.       });
  6.        it("should return correct result for positive integer parameter", function () {
  7.            expect(mathEnforcer.addFive(10)).to.be.equal(15);
  8.        });
  9.        it("should return correct result for negative integer parameter", function () {
  10.            expect(mathEnforcer.addFive(-5)).to.be.equal(0);
  11.        });
  12.        it("should return correct result for floating point parameter", function () {
  13.            expect(mathEnforcer.addFive(3.14)).to.be.closeTo(8.14, 0.01);
  14.        });
  15.    });
  16.  
  17.     describe('subtractTen', function () {
  18.         it("should return undefined for non-number parameter",function () {
  19.             expect(mathEnforcer.subtractTen("5")).to.be.equal(undefined);
  20.         });
  21.         it("should return correct result for positive integer parameter", function () {
  22.             expect(mathEnforcer.subtractTen(10)).to.be.equal(0);
  23.         });
  24.         it("should return correct result for negative integer parameter", function () {
  25.             expect(mathEnforcer.subtractTen(-5)).to.be.equal(-15);
  26.         });
  27.         it("should return correct result for floating point parameter", function () {
  28.             expect(mathEnforcer.subtractTen(3.14)).to.be.closeTo(-6.86, 0.01);
  29.         });
  30.     });
  31.  
  32.     describe('sum', function () {
  33.         it("should return undefined for non-number first parameter", function () {
  34.             expect(mathEnforcer.sum("5", 5)).to.be.equal(undefined);
  35.         });
  36.         it("should return undefined for non-number second parameter", function () {
  37.             expect(mathEnforcer.sum(5, "5")).to.be.equal(undefined);
  38.         });
  39.         it("should return correct result for integer parameters", function () {
  40.             expect(mathEnforcer.sum(5, -3)).to.be.equal(2);
  41.         });
  42.         it("should return correct result for floating point parameters", function () {
  43.             expect(mathEnforcer.sum(2.7, 3.4)).to.be.closeTo(6.1, 0.01);
  44.         })
  45.     })
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement