Skip to content

Commit adc1899

Browse files
gentarookaRendez
authored andcommitted
Accepted support test
1 parent b9c97e2 commit adc1899

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

test/fetch.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ describe('fetch', () => {
111111
expect(data.headers).not.toHaveProperty('content-type')
112112
})
113113

114+
it(`POST /accepted`, async () => {
115+
const fun = fetcher.path('/accepted').method('post').create()
116+
const { status, data } = await fun(undefined)
117+
expect(status).toBe(202)
118+
expect(data.message).toBe('Accepted')
119+
})
120+
114121
it(`POST /nocontent`, async () => {
115122
const fun = fetcher.path('/nocontent').method('post').create()
116123
const { status, data } = await fun(undefined)

test/mocks/handlers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const methods = {
4949
withBodyAndQuery: ['post', 'put', 'patch', 'delete'].map((method) => {
5050
return (rest as any)[method](`${HOST}/bodyquery/:id`, getResult)
5151
}),
52+
withAccepted: [
53+
rest.post(`${HOST}/accepted`, (req, res, ctx) => {
54+
return res(ctx.status(202), ctx.json({ message: 'Accepted' }))
55+
}),
56+
],
5257
withError: [
5358
rest.get(`${HOST}/error/:status`, (req, res, ctx) => {
5459
const status = Number(req.params.status)
@@ -81,5 +86,6 @@ export const handlers = [
8186
...methods.withBody,
8287
...methods.withBodyArray,
8388
...methods.withBodyAndQuery,
89+
...methods.withAccepted,
8490
...methods.withError,
8591
]

test/paths.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export type paths = {
6161
patch: BodyAndQuery
6262
delete: BodyAndQuery
6363
}
64+
'/accepted': {
65+
post: {
66+
parameters: {}
67+
responses: {
68+
202: { schema: { message: string } }
69+
}
70+
}
71+
}
6472
'/nocontent': {
6573
post: {
6674
parameters: {}

0 commit comments

Comments
 (0)