Skip to content
Permalink
e5a1f2539f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
19 lines (14 sloc) 444 Bytes
'use strict'
const app = require('./app')
const math = require('./math')
test('calls math.add', () => {
const addMock = jest.spyOn(math, 'add')
// override the implementation
addMock.mockImplementation(() => 'mock')
expect(app.doAdd(1, 2)).toEqual('mock')
expect(addMock).toHaveBeenCalledWith(1, 2)
// restore the original implementation
addMock.mockRestore()
expect(app.doAdd(1, 2)).toEqual(3)
console.log(addMock.mock.calls)
})