Skip to content

Commit

Permalink
test: add coverage for invalid URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Wheale committed Jan 5, 2023
1 parent 1e08f09 commit 0e890da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_scope.js
Expand Up @@ -47,6 +47,29 @@ describe('`Scope#constructor`', () => {
expect(() => nock('localhost/foo')).to.throw()
expect(() => nock('foo.com:1234')).to.throw()
})

it('throws on invalid URL format', async () => {
expect(() => nock(['This is not a url'])).to.throw()
// The following contains all valid properties of WHATWG URL, but is not an
// instance of URL. Maybe we should support object literals some day? A
// simple duck-type validator would suffice.
expect(() =>
nock({
href: 'http://google.com/foo',
origin: 'http://google.com',
protocol: 'http:',
username: '',
password: '',
host: 'google.com',
hostname: 'google.com',
port: 80,
pathname: '/foo',
search: '',
searchParams: {},
hash: '',
})
).to.throw()
})
})

describe('`Scope#remove()`', () => {
Expand Down

0 comments on commit 0e890da

Please sign in to comment.