25 lines
748 B
JavaScript
25 lines
748 B
JavaScript
import { applyDefaultContentType, isFormDataPayload } from '@/utils/request-payload'
|
|
|
|
describe('request payload content type policy', () => {
|
|
it('leaves FormData content type to the browser', () => {
|
|
const headers = {}
|
|
const data = new FormData()
|
|
|
|
applyDefaultContentType(headers, data)
|
|
|
|
expect(isFormDataPayload(data)).toBe(true)
|
|
expect(headers['Content-Type']).toBeUndefined()
|
|
})
|
|
|
|
it('keeps JSON defaults for ordinary payloads', () => {
|
|
const headers = {}
|
|
const data = { requestId: 'request-id' }
|
|
|
|
applyDefaultContentType(headers, data)
|
|
|
|
expect(isFormDataPayload(data)).toBe(false)
|
|
expect(isFormDataPayload(undefined)).toBe(false)
|
|
expect(headers['Content-Type']).toBe('application/json')
|
|
})
|
|
})
|