done spies
This commit is contained in:
parent
02cc9f37d3
commit
c9173a026d
@ -3,7 +3,7 @@ module.exports.handleSignup = (email, password) => {
|
||||
// Check if email already exists
|
||||
db.saveUser({
|
||||
email,
|
||||
pasword
|
||||
password
|
||||
});
|
||||
// Send welcome email
|
||||
|
||||
|
@ -1,9 +1,25 @@
|
||||
const expect = require('expect');
|
||||
const reqire = require('rewire');
|
||||
|
||||
var app = reqire('./app');
|
||||
// app.__set__
|
||||
// app.__get__
|
||||
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).toHaveBeenCalled('Andrew', 25);
|
||||
expect(spy).toHaveBeenCalledWith('Andrew', 25);
|
||||
});
|
||||
|
||||
it('should call saveUser with user object', () => {
|
||||
var email = 'tits@tits.com'
|
||||
var password = 'fakePass'
|
||||
app.handleSignup(email, password);
|
||||
expect(db.saveUser).toHaveBeenCalledWith({email, password})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user