Aliendreamer

js unit tests charlookup

Feb 22nd, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('lookupChar',function(){
  2.  
  3.     it('with a non-string first parameter should return undefined',function(){
  4.         expect(lookupChar(13,0)).to.equal(undefined,
  5.             'The function did not return the correct result!');
  6.     });
  7.  
  8.     it('with a non-number second parameter should return undefined',function(){
  9.         expect(lookupChar('pesho','gosho')).to.equal(undefined,
  10.             'The function did not return the correct result!');
  11.     });
  12.  
  13.    
  14.     it('with a floating point second parameter should return undefined',function(){
  15.         expect(lookupChar('pesho',3.12)).to.equal(undefined,
  16.             'The function did not return the correct result!');
  17.     });
  18.  
  19.    
  20.     it('with an incorrect index value should return incorrect index',function(){
  21.         expect(lookupChar('gosho',13)).to.equal('Incorrect index',
  22.             'The function did not return the correct result!');
  23.     });
  24.  
  25.     it('with a negative index value should return incorrect index',function(){
  26.         expect(lookupChar('stamat',-1)).to.equal('Incorrect index',
  27.             'The function did not return the correct result!');
  28.     });
  29.  
  30.     it('with an index value equal to string length should return Incorrect index',function(){
  31.         expect(lookupChar('pesho',5)).to.equal('Incorrect index',
  32.             'The function did not return the correct result!');
  33.     });
  34.  
  35.     it('with correct parameters should return correct value',function(){
  36.         expect(lookupChar('pesho',0)).to.equal('p',
  37.             'The function did not return the correct result!');
  38.     });
  39.  
  40.     it('with correct parameters should return correct value',function(){
  41.         expect(lookupChar('stamat',3)).to.equal('m',
  42.             'The function did not return the correct result!');
  43.     });
  44. });
Advertisement
Add Comment
Please, Sign In to add comment