Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
msutkowski committed Jun 10, 2022
1 parent 8cf042b commit ddc16a2
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,27 @@ describe('fetchBaseQuery', () => {
expect(request.headers['content-type']).toBe('text/html')
expect(request.body).toEqual(data.join(','))
})

it('supports a custom jsonContentType', async () => {
const baseQuery = fetchBaseQuery({
baseUrl,
fetchFn: fetchFn as any,
jsonContentType: 'application/vnd.api+json',
})

let request: any
;({ data: request } = await baseQuery(
{
url: '/echo',
body: {},
method: 'POST',
},
commonBaseQueryApi,
{}
))

expect(request.headers['content-type']).toBe('application/vnd.api+json')
})
})

describe('arg.params', () => {
Expand Down Expand Up @@ -408,9 +429,11 @@ describe('fetchBaseQuery', () => {
baseUrl,
fetchFn: fetchFn as any,
isJsonContentType: (headers) =>
['application/vnd.api+json', 'application/json', 'application/vnd.hal+json'].includes(
headers.get('content-type') ?? ''
),
[
'application/vnd.api+json',
'application/json',
'application/vnd.hal+json',
].includes(headers.get('content-type') ?? ''),
})

let request: any
Expand Down

0 comments on commit ddc16a2

Please sign in to comment.