feat: initial test suite framework (#4929)
This commit is contained in:
@@ -15,8 +15,8 @@ export default buildConfigWithDefaults({
|
||||
{
|
||||
path: '/hello',
|
||||
method: 'get',
|
||||
handler: (_, res): void => {
|
||||
res.json({ message: 'hi' })
|
||||
handler: () => {
|
||||
return Response.json({ message: 'hi' })
|
||||
},
|
||||
custom: { examples: [{ type: 'response', value: { message: 'hi' } }] },
|
||||
},
|
||||
@@ -38,9 +38,9 @@ export default buildConfigWithDefaults({
|
||||
{
|
||||
path: '/greet',
|
||||
method: 'get',
|
||||
handler: (req, res): void => {
|
||||
const { name } = req.query
|
||||
res.json({ message: `Hi ${name}!` })
|
||||
handler: ({ req }) => {
|
||||
const sp = new URL(req.url).searchParams
|
||||
return Response.json({ message: `Hi ${sp.get('name')}!` })
|
||||
},
|
||||
custom: { params: [{ in: 'query', name: 'name', type: 'string' }] },
|
||||
},
|
||||
@@ -60,8 +60,8 @@ export default buildConfigWithDefaults({
|
||||
path: '/config',
|
||||
method: 'get',
|
||||
root: true,
|
||||
handler: (req, res): void => {
|
||||
res.json(req.payload.config)
|
||||
handler: ({ req }) => {
|
||||
return Response.json(req.payload.config)
|
||||
},
|
||||
custom: { description: 'Get the sanitized payload config' },
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('Config', () => {
|
||||
|
||||
it('allows a custom field in collection endpoints', () => {
|
||||
const [collection] = payload.config.collections
|
||||
const [endpoint] = collection.endpoints
|
||||
const [endpoint] = collection.endpoints || []
|
||||
|
||||
expect(endpoint.custom).toEqual({
|
||||
examples: [{ type: 'response', value: { message: 'hi' } }],
|
||||
@@ -52,7 +52,7 @@ describe('Config', () => {
|
||||
|
||||
it('allows a custom field in global endpoints', () => {
|
||||
const [global] = payload.config.globals
|
||||
const [endpoint] = global.endpoints
|
||||
const [endpoint] = global.endpoints || []
|
||||
|
||||
expect(endpoint.custom).toEqual({ params: [{ in: 'query', name: 'name', type: 'string' }] })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user