forked from testdouble/testdouble-jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
td-replace.test.js
39 lines (31 loc) · 926 Bytes
/
td-replace.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
let bar, baz, qux, quux, subject
describe('td.replace', () => {
beforeEach(() => {
bar = td.replace('./bar')
baz = td.replace('./baz', () => 'woot')
qux = td.replace('./qux', () => 'so fake!')
quux = td.replace('./quux', td.func('quux'))
subject = require('./foo')
})
it('tdjs will imitate the dep with no-args', () => {
td.when(bar(42)).thenReturn('yay!')
const result = subject()
expect(result.bar).toEqual('yay!')
})
it('td.reset() will not pollute stubbings', () => {
const result = subject()
expect(result.bar).toEqual(undefined)
})
it('can pass a factory', () => {
const result = subject()
expect(result.baz).toEqual('woot')
})
it('can pass the virtual option, too', () => {
const result = subject()
expect(result.qux).toEqual('so fake!')
})
it('can assert a call', () => {
subject()
td.verify(quux(1337), {times: 1})
})
})