Skip to content

Commit

Permalink
🖐
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Jun 10, 2024
1 parent 8ced764 commit 94a4c77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/url-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
38 changes: 19 additions & 19 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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('')
})
})

0 comments on commit 94a4c77

Please sign in to comment.