Advertisement
Niicksana

07. Add / Subtract

Jun 9th, 2022 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('It should return module(object)', () => {
  2.     it('Return object', () => {
  3.         expect(typeof createCalculator()).to.equal('object');
  4.     });
  5.  
  6.     it('Contains add property', () => {
  7.         expect(createCalculator()).to.have.property('add');
  8.     });
  9.  
  10.     it('Contains subtract property', () => {
  11.         expect(createCalculator()).to.have.property('subtract');
  12.     });
  13.  
  14.     it('Contains get property', () => {
  15.         expect(createCalculator()).to.have.property('get');
  16.     });
  17.  
  18.     it('Return a function', () => {
  19.         expect(typeof createCalculator().add).to.equal('function');
  20.     });
  21.  
  22.     it('Return a function', () => {
  23.         expect(typeof createCalculator().subtract).to.equal('function');
  24.     });
  25.  
  26.     it('Return a function', () => {
  27.         expect(typeof createCalculator().get).to.equal('function');
  28.     });
  29.  
  30.     let calc = createCalculator();
  31.  
  32.     it('Add to parse string number', () => {
  33.         calc.add('1');
  34.         expect(calc.get()).to.equal(1);
  35.     });
  36.  
  37.     it('Subtract to parse string number', () => {
  38.         calc.subtract('2');
  39.         expect(calc.get()).to.equal(-1);
  40.     });
  41.  
  42.     it('Add a number', () => {
  43.         calc.add(2);
  44.         expect(calc.get()).to.equal(1);
  45.     });
  46.  
  47.     it('Subtract a number', () => {
  48.         calc.subtract(2);
  49.         expect(calc.get()).to.equal(-1);
  50.     });
  51.  
  52.     it('Add a number', () => {
  53.         calc.add(2);
  54.         expect(calc.get()).to.equal(1);
  55.     });
  56.  
  57.     it('Return the value', () => {
  58.         expect(typeof calc.get()).to.equal('number');
  59.         expect(calc.get()).to.equal(1);
  60.     });
  61.  
  62.     it('String params to return NaN', () => {
  63.         let calc = createCalculator();
  64.         calc.add('string');
  65.         expect(calc.get()).to.be.NaN;
  66.     })
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement