-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: now more spec compliant on exceptions
- Loading branch information
1 parent
0b40de7
commit ceec07f
Showing
5 changed files
with
44 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,38 +12,33 @@ describe('Spec compliance', () => { | |
'has space': 'ok', | ||
}, | ||
}), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
}); | ||
it('reject on invalid header value', async () => { | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { | ||
headers: [['a', 'b', 'c']], | ||
}), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
).rejects.toThrow(new TypeError('Invalid name')); | ||
}); | ||
it('reject on url containing credentials', async () => { | ||
await expect( | ||
fetchMock.fetchHandler('http://user:[email protected]'), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
}); | ||
it('reject on invalid modes', async () => { | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { mode: 'websocket' }), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { mode: 'navigate' }), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
).rejects.toThrow( | ||
new TypeError( | ||
'Request cannot be constructed from a URL that includes credentials: http://user:[email protected]/', | ||
), | ||
); | ||
}); | ||
it('reject if the request method is GET or HEAD and the body is non-null.', async () => { | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { body: 'a' }), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
).rejects.toThrow( | ||
new TypeError('Request with GET/HEAD method cannot have body.'), | ||
); | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { body: 'a', method: 'GET' }), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
).rejects.toThrow( | ||
new TypeError('Request with GET/HEAD method cannot have body.'), | ||
); | ||
await expect( | ||
fetchMock.fetchHandler('http://a.com', { body: 'a', method: 'HEAD' }), | ||
).rejects.toThrow(new TypeError('asdasdsa')); | ||
).rejects.toThrow( | ||
new TypeError('Request with GET/HEAD method cannot have body.'), | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters