Files
admin-web/src/shared/api/http.safe-integer.test.ts
T
2026-08-03 18:49:18 +08:00

16 lines
505 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parseApiJsonResponse, parseJsonWithSafeIntegers } from '@chongchong/shared'
describe('safe integer API parsing', () => {
it('preserves backend long IDs as strings', () => {
expect(parseJsonWithSafeIntegers('{"id":2082674456475418625,"page":1}')).toEqual({
id: '2082674456475418625',
page: 1,
})
})
it('leaves non-JSON responses untouched', () => {
expect(parseApiJsonResponse('plain text')).toBe('plain text')
})
})