Skip to content

Commit 09181cb

Browse files
committed
fix: send filter parameters to responses
1 parent ab78174 commit 09181cb

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

src/responses.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ const getResponses = (
2020
return http.request({
2121
method: 'get',
2222
url: `/forms/${uid}/responses`,
23-
page_size: pageSize,
24-
since,
25-
until,
26-
after,
27-
before,
28-
completed,
29-
sort,
30-
query,
31-
fields
23+
params: {
24+
page_size: pageSize,
25+
since,
26+
until,
27+
after,
28+
before,
29+
completed,
30+
sort,
31+
query,
32+
fields
33+
}
3234
})
3335
}

tests/unit/responses.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ test('List responses has the correct path and method', () => {
1616
expect(fetch.mock.calls[0][1].method).toBe('get')
1717
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms/2/responses`)
1818
})
19+
20+
test('List responses with the given filters', () => {
21+
const http = clientConstructor({
22+
token: '123',
23+
})
24+
const responsesRequest = responses(http)
25+
responsesRequest.list({ uid: 2, pageSize: 15, after: '12345' })
26+
const params = (new URL(fetch.mock.calls[0][0])).searchParams
27+
expect(params.get('page_size')).toBe('15')
28+
expect(params.get('after')).toBe('12345')
29+
})

tests/unit/themes.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ test('Get themes has the correct path', () => {
3030

3131
test('Get themes has the correct parameters', () => {
3232
themesRequest.list({ page: 3, pageSize: 15 })
33-
expect(fetch.mock.calls[0][1].params.page).toBe(3)
34-
expect(fetch.mock.calls[0][1].params.page_size).toBe(15)
33+
const params = (new URL(fetch.mock.calls[0][0])).searchParams
34+
expect(params.get('page')).toBe('3')
35+
expect(params.get('page_size')).toBe('15')
3536
})
3637

3738
test('Get themes has the correct path', () => {

0 commit comments

Comments
 (0)