Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Send range header in simple REST client getList request
- Loading branch information
1 parent
7223b23
commit 4a60ffa
Showing
2 changed files
with
50 additions
and
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import simpleClient from '.'; | ||
|
|
||
| describe('Data Simple REST Client', () => { | ||
| describe('getList', () => { | ||
| it('should include the `Range` header in request (for Chrome compatibility purpose)', async () => { | ||
| const httpClient = jest.fn(() => | ||
| Promise.resolve({ | ||
| headers: new Headers({ | ||
| 'content-range': '0/4-8', | ||
| }), | ||
| }) | ||
| ); | ||
| const client = simpleClient('http://localhost:3000', httpClient); | ||
|
|
||
| await client.getList('posts', { | ||
| filter: {}, | ||
| pagination: { | ||
| page: 1, | ||
| perPage: 10, | ||
| }, | ||
| sort: { | ||
| field: 'title', | ||
| order: 'desc', | ||
| }, | ||
| }); | ||
|
|
||
| expect(httpClient).toHaveBeenCalledWith( | ||
| 'http://localhost:3000/posts?filter=%7B%7D&range=%5B0%2C9%5D&sort=%5B%22title%22%2C%22desc%22%5D', | ||
| { | ||
| headers: { | ||
| map: { | ||
| range: 'posts=0-9', | ||
| }, | ||
| }, | ||
| } | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
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