Skip to content

Commit 665ad34

Browse files
committed
fix: send parameters to forms request
1 parent 09181cb commit 665ad34

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/forms.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ export default http => ({
1010
}
1111
})
1212

13-
const getForms = (http, { page, pageSize, search } = {}) => {
13+
const getForms = (http, { page, pageSize, search, workspaceId } = {}) => {
1414
return http.request({
1515
method: 'get',
1616
url: `/forms`,
17-
page,
18-
page_size: pageSize,
19-
search
17+
params: {
18+
page,
19+
page_size: pageSize,
20+
search,
21+
workspace_id: workspaceId
22+
}
2023
})
2124
}
2225

tests/unit/forms.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,27 @@ const formsRequest = forms(http)
1414

1515
test('get all forms has the correct method and path', () => {
1616
formsRequest.list()
17-
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms`)
17+
18+
const url = fetch.mock.calls[0][0].split('?')
19+
expect(url[0]).toBe(`${API_BASE_URL}/forms`)
1820
expect(fetch.mock.calls[0][1].method).toBe('get')
1921
})
2022

23+
test('paramters are sent correctly', () => {
24+
formsRequest.list({
25+
page: 2,
26+
pageSize: 10,
27+
search: 'hola',
28+
workspaceId: 'abc'
29+
})
30+
const url = fetch.mock.calls[0][0].split('?')
31+
const params = new URLSearchParams(url[1])
32+
expect(params.get('page')).toBe('2')
33+
expect(params.get('page')).toBe('2')
34+
expect(params.get('page')).toBe('2')
35+
expect(params.get('page')).toBe('2')
36+
})
37+
2138
test('getForm sends the correct UID', () => {
2239
formsRequest.get({ uid: 'abc123' })
2340
expect(fetch.mock.calls[0][0]).toBe(`${API_BASE_URL}/forms/abc123`)

0 commit comments

Comments
 (0)