Skip to content

Commit dfe7bbd

Browse files
authored
mock: improve validateReplyParameters (#2783)
1 parent ff4c57a commit dfe7bbd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/mock/mock-interceptor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class MockInterceptor {
106106
if (typeof data === 'undefined') {
107107
throw new InvalidArgumentError('data must be defined')
108108
}
109-
if (typeof responseOptions !== 'object') {
109+
if (typeof responseOptions !== 'object' || responseOptions === null) {
110110
throw new InvalidArgumentError('responseOptions must be an object')
111111
}
112112
}

test/mock-interceptor.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ describe('MockInterceptor - reply callback', () => {
5353
})
5454

5555
test('should error if passed options invalid', t => {
56-
t = tspl(t, { plan: 2 })
56+
t = tspl(t, { plan: 3 })
5757

5858
const mockInterceptor = new MockInterceptor({
5959
path: '',
6060
method: ''
6161
}, [])
6262
t.throws(() => mockInterceptor.reply(), new InvalidArgumentError('statusCode must be defined'))
6363
t.throws(() => mockInterceptor.reply(200, () => { }, 'hello'), new InvalidArgumentError('responseOptions must be an object'))
64+
t.throws(() => mockInterceptor.reply(200, () => { }, null), new InvalidArgumentError('responseOptions must be an object'))
6465
})
6566
})
6667

0 commit comments

Comments
 (0)