Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Benedetti committed Nov 3, 2022
1 parent 45cdd67 commit b0145da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/utils/__tests__/http-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,29 @@ describe('http-client tests', () => {
expect(headers.get('Content-Disposition')).toStrictEqual('attachment; filename=file.csv')
})

it('should fetch a post method with file download and without filename', async () => {
const body = {key: 'value'}
fetchMock.mockOnceIf(/\/$/, () => {
return Promise.resolve({
status: 200,
body: 'text',
headers: {
'Content-Type': 'text/plain'
}
})
})

const {
headers, status
} = await createFetchHttpClient.bind<() => HttpClientInstance>(support)().post('/', body, {
downloadAsFile: true
})

expect(downloadFile).toBeCalled()
expect(status).toBe(200)
expect(headers.get('Content-Type')).toStrictEqual('text/plain')
})

it('should fetch post method with text response applying a transform', async () => {
const body = {key: 'value'}
const modBody = {key: 'value1'}
Expand Down

0 comments on commit b0145da

Please sign in to comment.