pull/659/head
Travis Fischer 2024-06-09 19:20:28 -05:00
rodzic 8ced7643c8
commit 94a4c7763f
2 zmienionych plików z 26 dodań i 26 usunięć

Wyświetl plik

@ -20,12 +20,12 @@ describe('normalizeUrl', () => {
})
test('invalid urls', async () => {
expect(normalizeUrl('/foo')).toBe(null)
expect(normalizeUrl('/foo/bar/baz')).toBe(null)
expect(normalizeUrl('://foo.com')).toBe(null)
expect(normalizeUrl('foo')).toBe(null)
expect(normalizeUrl('')).toBe(null)
expect(normalizeUrl(undefined as unknown as string)).toBe(null)
expect(normalizeUrl(null as unknown as string)).toBe(null)
expect(normalizeUrl('/foo')).toBe(undefined)
expect(normalizeUrl('/foo/bar/baz')).toBe(undefined)
expect(normalizeUrl('://foo.com')).toBe(undefined)
expect(normalizeUrl('foo')).toBe(undefined)
expect(normalizeUrl('')).toBe(undefined)
expect(normalizeUrl(undefined as unknown as string)).toBe(undefined)
expect(normalizeUrl(null as unknown as string)).toBe(undefined)
})
})

Wyświetl plik

@ -52,6 +52,25 @@ test('sanitizeSearchParams', () => {
expect(sanitizeSearchParams({ a: [] }).toString()).toMatchSnapshot()
})
describe('stringifyForModel', () => {
test('handles basic objects', () => {
const input = {
foo: 'bar',
nala: ['is', 'cute'],
kittens: null,
cats: undefined,
paws: 4.3
}
const result = stringifyForModel(input)
expect(result).toEqual(JSON.stringify(input, null))
})
test('handles empty input', () => {
const result = stringifyForModel()
expect(result).toEqual('')
})
})
test(
'throttleKy should rate-limit requests to ky properly',
async () => {
@ -85,22 +104,3 @@ test(
timeout: 60_000
}
)
describe('stringifyForModel', () => {
test('handles basic objects', () => {
const input = {
foo: 'bar',
nala: ['is', 'cute'],
kittens: null,
cats: undefined,
paws: 4.3
}
const result = stringifyForModel(input)
expect(result).toEqual(JSON.stringify(input, null))
})
test('handles empty input', () => {
const result = stringifyForModel()
expect(result).toEqual('')
})
})