Skip to content

Commit

Permalink
remove test implementations that don't actually test the described fe…
Browse files Browse the repository at this point in the history
…ature

`fetch` API doesn't allow sending a body with GET requests
  • Loading branch information
Lordfirespeed committed Sep 22, 2024
1 parent 65e64c8 commit d37e626
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 61 deletions.
16 changes: 1 addition & 15 deletions tests/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ test('should parse custom body', async () => {
}).expect(200, 'HELLO WORLD')
})

test('custom should ignore GET request', async () => {
const server = createServer(async (req: Request, res) => {
const body = await custom(req, res)

res.setHeader('Content-Type', 'text/plain')

res.end(body == null ? 'GET is ignored' : 'GET is not ignored')
})
test.skip('custom should ignore GET request', async () => {

await makeFetch(server)('/', {
method: 'GET',
headers: {
Accept: 'text/plain',
'Content-Type': 'text/plain',
},
}).expect(200, 'GET is ignored')
})
9 changes: 2 additions & 7 deletions tests/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ it('should not parse json body with no content-type headers', async () => {
await expect(response.text()).resolves.toEqual('')
})

it('should ignore GET requests', async () => {
const fetch = createFetch()
const response = await fetch({
method: 'GET',
})
expect(response.status).toBe(200)
await expect(response.text()).resolves.toEqual('')
it.skip('should ignore GET requests', async () => {

})

describe('with invalid JSON body', () => {
Expand Down
16 changes: 1 addition & 15 deletions tests/raw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ test('should parse raw body', async () => {
}).expect(200, 'hello world')
})

test('raw should ignore GET request', async () => {
const server = createServer(async (req: Request, res) => {
const body = await raw(req, res)

res.setHeader('Content-Type', 'text/plain')

res.end('GET is ignored')
})
test.skip('raw should ignore GET request', async () => {

await makeFetch(server)('/', {
method: 'GET',
headers: {
Accept: 'text/plain',
'Content-Type': 'text/plain',
},
}).expect(200, 'GET is ignored')
})
16 changes: 1 addition & 15 deletions tests/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ test('should parse text body', async () => {
}).expect(200, 'hello world')
})

test('text should ignore GET request', async () => {
const server = createServer(async (req: Request, res) => {
await text(req, res)

res.setHeader('Content-Type', 'text/plain')

res.end('GET is ignored')
})
test.skip('text should ignore GET request', async () => {

await makeFetch(server)('/', {
method: 'GET',
headers: {
Accept: 'text/plain',
'Content-Type': 'text/plain',
},
}).expect(200, 'GET is ignored')
})
10 changes: 1 addition & 9 deletions tests/urlencoded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ test('should parse urlencoded body', async () => {
}).expect(200, { hello: 'world' })
})

test('urlencoded should ignore GET request', async () => {
const server = createServer(async (req: Request, res) => {
const body = await urlencoded(req, res)
test.skip('urlencoded should ignore GET request', async () => {

res.end('GET is ignored')
})

await makeFetch(server)('/', {
method: 'GET',
}).expect(200, 'GET is ignored')
})

0 comments on commit d37e626

Please sign in to comment.