Advertisement
Guest User

addSubtract

a guest
Oct 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("createCalculator", function () {
  2.     let calc;
  3.     beforeEach(function () {
  4.         calc = createCalculator();
  5.     });
  6.  
  7.     it("should return 5 after {add 3; add 2}", function () {
  8.         calc.add(3);
  9.         calc.add(2);
  10.         let result = calc.get();
  11.         expect(result).equal(5);
  12.     });
  13.  
  14.     it("should return 0 for get()",function () {
  15.         expect(calc.get()).equal(0);
  16.     });
  17.  
  18.     it("should return -5 for {subtract 2;subract 3}",function () {
  19.         calc.subtract(2);
  20.         calc.subtract(3);
  21.         let result = calc.get();
  22.         expect(result).equal(-5);
  23.     });
  24.  
  25.     it("should return 4.4 for {add 5.3;subract 1.1}",function () {
  26.         calc.add(5.3);
  27.         calc.subtract(1.2);
  28.         expect(calc.get()).equal(4.1);
  29.     });
  30.  
  31.     it("should return 2 for {add 10; subract \'7\'; add \'-2\'; subtract -1}",function () {
  32.         calc.add(10);
  33.         calc.subtract('7');
  34.         calc.add('-2');
  35.         calc.subtract(-1);
  36.         expect(calc.get()).equal(2);
  37.     });
  38.  
  39.     it("should return NaN for {add \'hello\'}",function () {
  40.         calc.add('hello');
  41.         expect(calc.get()).to.be.NaN;
  42.     });
  43.  
  44.     it("should return Nan for {subract \'hello\'",function () {
  45.         calc.subtract('hello');
  46.         expect(calc.get()).to.be.NaN;
  47.     });
  48.  
  49.     it("should return 1 for {add \"1\"",function () {
  50.         calc.add("1");
  51.         expect(calc.get()).equal(1);
  52.     });
  53.  
  54.     it("should return -6 for {add -3: subtract 3",function () {
  55.         calc.add(-3);
  56.         calc.subtract(3);
  57.         expect(calc.get()).equal(-6);
  58.     });
  59.  
  60.     it("should return   for {add -3: subtract -3",function () {
  61.         calc.add(-3);
  62.         calc.subtract(-3);
  63.         expect(calc.get()).equal(0);
  64.     });
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement