done spies

This commit is contained in:
Tyrel Souza 2017-11-28 22:58:36 -05:00
parent 02cc9f37d3
commit c9173a026d
2 changed files with 19 additions and 3 deletions

View File

@ -3,7 +3,7 @@ module.exports.handleSignup = (email, password) => {
// Check if email already exists
db.saveUser({
email,
pasword
password
});
// Send welcome email

View File

@ -1,9 +1,25 @@
const expect = require('expect');
const reqire = require('rewire');
var app = reqire('./app');
// app.__set__
// app.__get__
describe('App', () => {
it('should call the spy correctly',() => {
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})
})
})