Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,36 @@ describe('API Request Handler', () => {
expect(text).toBe('Success')
})

it('should ignore query strings for a valid GET request', async () => {
const request = new Request(
'https://starbasedb.test.workers.dev/api/your/path/here?source=test',
{
method: 'GET',
}
)

const response = await handleApiRequest(request)

expect(response.status).toBe(200)
const text = await response.text()
expect(text).toBe('Success')
})

it('should return 404 when the path has a trailing slash', async () => {
const request = new Request(
'https://starbasedb.test.workers.dev/api/your/path/here/',
{
method: 'GET',
}
)

const response = await handleApiRequest(request)

expect(response.status).toBe(404)
const text = await response.text()
expect(text).toBe('Not found')
})

it('should return 404 for an unknown GET request', async () => {
const request = new Request(
'https://starbasedb.test.workers.dev/api/unknown',
Expand Down