Skip to content

Commit 16ddec5

Browse files
chore: add unit tests
1 parent 8663895 commit 16ddec5

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/mock-interceptor.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ test('MockInterceptor - reply', t => {
3030
})
3131
})
3232

33+
test('MockInterceptor - reply callback', t => {
34+
t.plan(2)
35+
36+
t.test('should return MockScope', t => {
37+
t.plan(1)
38+
const mockInterceptor = new MockInterceptor({
39+
path: '',
40+
method: ''
41+
}, [])
42+
const result = mockInterceptor.reply(200, () => 'hello')
43+
t.type(result, MockScope)
44+
})
45+
46+
t.test('should error if passed options invalid', t => {
47+
t.plan(2)
48+
49+
const mockInterceptor = new MockInterceptor({
50+
path: '',
51+
method: ''
52+
}, [])
53+
t.throws(() => mockInterceptor.reply(), new InvalidArgumentError('statusCode must be defined'))
54+
t.throws(() => mockInterceptor.reply(200, () => {}, 'hello'), new InvalidArgumentError('responseOptions must be an object'))
55+
})
56+
})
57+
3358
test('MockInterceptor - replyWithError', t => {
3459
t.plan(2)
3560

0 commit comments

Comments
 (0)