Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
28 lines
994 B
TypeScript
28 lines
994 B
TypeScript
import { AxiosHeaders } from 'axios'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { FORM_DATA_UPLOAD_TIMEOUT_MS, applyFormDataRequestDefaults } from '@/lib/formDataRequest'
|
|
|
|
describe('applyFormDataRequestDefaults', () => {
|
|
it('strips stale Content-Type before Axios transforms FormData', () => {
|
|
const config = applyFormDataRequestDefaults({
|
|
data: new FormData(),
|
|
headers: AxiosHeaders.from({ 'Content-Type': 'multipart/form-data' }),
|
|
} as never)
|
|
|
|
expect(AxiosHeaders.from(config.headers).get('Content-Type')).toBeUndefined()
|
|
expect(config.timeout).toBe(FORM_DATA_UPLOAD_TIMEOUT_MS)
|
|
})
|
|
|
|
it('leaves JSON requests unchanged', () => {
|
|
const config = applyFormDataRequestDefaults({
|
|
data: { ok: true },
|
|
headers: AxiosHeaders.from({ 'Content-Type': 'application/json' }),
|
|
timeout: 0,
|
|
} as never)
|
|
|
|
expect(AxiosHeaders.from(config.headers).get('Content-Type')).toBe('application/json')
|
|
expect(config.timeout).toBe(0)
|
|
})
|
|
})
|