fix: bodyless posts no longer send json content-type (fastify 400 on empty body)
This commit is contained in:
@@ -40,4 +40,19 @@ describe('api additions', () => {
|
||||
expect(err).toBeInstanceOf(ApiError)
|
||||
expect((err as ApiError).code).toBe('no_subsonic_config')
|
||||
})
|
||||
|
||||
it('bodyless posts do not send a json content-type (Fastify 400s on empty json bodies)', async () => {
|
||||
fetchMock.mockClear()
|
||||
fetchMock.mockImplementation(() => jsonOk({ ok: true }))
|
||||
await api.returnLoan(7)
|
||||
await api.markPlayed('a1')
|
||||
await api.logout()
|
||||
await api.triggerBackup()
|
||||
for (const call of fetchMock.mock.calls) {
|
||||
const init = call[1] as RequestInit | undefined
|
||||
const headers = (init?.headers ?? {}) as Record<string, string>
|
||||
expect(headers['Content-Type']).toBeUndefined()
|
||||
expect(init?.body).toBeUndefined()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user