Skip to content

Commit

Permalink
fix(types): DataMatcher to allow valid JSON scalars. (#1703)
Browse files Browse the repository at this point in the history
Fixes: #1702
  • Loading branch information
mastermatt committed Sep 4, 2019
1 parent 9d5cda0 commit a700fa2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion types/index.d.ts
Expand Up @@ -37,12 +37,16 @@ declare namespace nock {
interceptorOptions?: Options
) => Interceptor

// essentially valid decoded JSON with the addition of possible RegExp
interface DataMatcher {
[k: string]:
| boolean
| null
| number
| string
| RegExp
| DataMatcher
| Array<string | RegExp | DataMatcher>
| Array<boolean | null | number | string | RegExp | DataMatcher>
}

type RequestBodyMatcher =
Expand Down
9 changes: 9 additions & 0 deletions types/tests.ts
Expand Up @@ -182,6 +182,15 @@ scope = nock('http://example.test')
rev: '946B7D1C',
})

nock('https://example.test')
.post('/path', {
number: 1,
bool: false,
empty: null,
array: ['foo', 2, true, null, { number: 3 }],
})
.reply(200)

scope = nock('http://example.test')
.post('/users', /email=.?@example.test/gi)
.reply(201, {
Expand Down

0 comments on commit a700fa2

Please sign in to comment.