-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getMany fails when called with an empty array of ids (#165)
Closes #158
- Loading branch information
1 parent
7c896f5
commit 812f2c4
Showing
2 changed files
with
28 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { makeTestFromCase, Case } from './helper'; | ||
import dataProviderBuilder from '../../src'; | ||
|
||
describe('getMany specific', () => { | ||
const method = 'getMany'; | ||
|
||
const cases: Case[] = [ | ||
{ | ||
test: 'Read a list of resource, by ids', | ||
method, | ||
resource: 'posts', | ||
params: { ids: [1, 2, 3] }, | ||
expectedUrl: `/posts?id=in.%28${encodeURIComponent('1,2,3')}%29`, | ||
expectedOptions: { headers: {} }, | ||
}, | ||
]; | ||
|
||
cases.forEach(makeTestFromCase); | ||
|
||
it('should not fail when no ids are provided', async () => { | ||
const dataProvider = dataProviderBuilder({} as any); | ||
const { data } = await dataProvider.getMany('posts', { ids: [] }); | ||
expect(data).toEqual([]); | ||
}); | ||
}); |