SHARE
TWEET

Untitled

a guest Aug 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import multiply from './multiply';
  2.  
  3. // pretend we can "spy on" for loops, or worse, that
  4. // you refactor your code to call an add() method which
  5. // you spy on and then expect it to be called N times..
  6. test('given 2 and 5, it should loop 5 times', () => {
  7.   spyOn(for); // hol' up: pretend we can spy on for loops 🕶
  8.  
  9.   const a = 2;
  10.   const b = 5;
  11.   const expectedCount = 5;
  12.  
  13.   multiply(a, b);
  14.  
  15.   expect(for).toHaveBeenCalledTimes(expectedCount);
  16. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top