January 2018
Beginner
658 pages
13h 10m
English
To verify if handleSignup calls saveUser, inside app.test.js, we'll call it:
describe('App', () => { var db = { saveUser: expect.createSpy() }; app.__set__('db', db); it('should call the spy correctly', () => { var spy = expect.createSpy(); spy('Andrew', 25); expect(spy).toHaveBeenCalledWith('Andrew', 25); }); it('should call saveUser with user object')
Then we can pass in our function, and this is what will actually run when the test gets executed, and there's no need to use any asynchronous done arguments. This will be a synchronous test for now:
it('should call saveUser with user object', () => { });
Inside the callback function, we can come up with an email and a password that we'll pass ...
Read now
Unlock full access