-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds check to throw if http status is not 200 (#78)
BREAKING CHANGE
- Loading branch information
Showing
5 changed files
with
49 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { unfurl } from '../../src' | ||
import nock from 'nock' | ||
import UnexpectedError from '../../src/unexpectedError' | ||
|
||
test('should throw if status code not 200', () => { | ||
nock('http://localhost') | ||
.get('/html/return-404') | ||
.reply(404) | ||
|
||
return expect(unfurl('http://localhost/html/return-404')) | ||
.rejects | ||
.toThrow(new UnexpectedError(UnexpectedError.BAD_HTTP_STATUS)) | ||
}) | ||
|
||
test('should not throw if status code is 200', async () => { | ||
nock('http://localhost') | ||
.get('/html/return-200') | ||
.reply(200, '', { | ||
'Content-Type': 'text/html' | ||
}) | ||
|
||
return expect(unfurl('http://localhost/html/return-200')) | ||
.resolves | ||
.toBeTruthy() | ||
}) | ||
|
4b6e032
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes #77