-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): Fixed issue with requesting JavaScript objects via fetch()
(#12)
- Loading branch information
Showing
8 changed files
with
58 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ import chaiAsPromised from 'chai-as-promised'; | |
import fetchMock from 'fetch-mock'; | ||
import Client from './Client'; | ||
import { NotFoundResponse, ServerErrorResponse } from './responses'; | ||
import { toBlob } from './testutils'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
@@ -68,9 +67,10 @@ describe('When using the client to make POST requests', () => { | |
}); | ||
|
||
it('should make a successful POST request', () => { | ||
const body = new FormData(); | ||
body.append('username', '[email protected]'); | ||
body.append('password', 'securepassword'); | ||
const body = Client.toBlob({ | ||
username: '[email protected]', | ||
password: 'securepassword', | ||
}); | ||
|
||
return client.post('/success', { body }) | ||
.then(response => response.json()) | ||
|
@@ -89,7 +89,7 @@ describe('When handling errors in requests through the client', () => { | |
beforeEach(() => { | ||
fetchMock | ||
.get('http://example.com/failure/404', new Response(new Blob(), { status: 404 })) | ||
.get('http://example.com/failure/500', new Response(toBlob(serverErrorResponse), { status: 500 })) | ||
.get('http://example.com/failure/500', new Response(Client.toBlob(serverErrorResponse), { status: 500 })) | ||
.catch(503); | ||
}); | ||
afterEach(fetchMock.restore); | ||
|
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
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