Skip to content

Commit

Permalink
feat: remove accountId from most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Sep 21, 2023
1 parent 516b900 commit 3fd4cbf
Showing 1 changed file with 6 additions and 41 deletions.
47 changes: 6 additions & 41 deletions packages/openapi/src/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,6 @@ describe('OpenAPI Validator', (): void => {
next = jest.fn()
})

test.each`
accountId | message | description
${undefined} | ${"must have required property 'accountId'"} | ${'missing'}
${2} | ${'accountId must be string'} | ${'invalid'}
`(
'returns 400 on $description path parameter',
async ({ accountId, message }): Promise<void> => {
const ctx = createContext(
{
headers: { Accept: 'application/json' }
},
{
accountId
}
)
await expect(validateListMiddleware(ctx, next)).rejects.toMatchObject({
status: 400,
message
})
expect(next).not.toHaveBeenCalled()
}
)

test('coerces query parameter type', async (): Promise<void> => {
const first = 5
const next = jest.fn().mockImplementation(() => {
Expand All @@ -100,9 +77,7 @@ describe('OpenAPI Validator', (): void => {
headers: { Accept: 'application/json' },
url: `${PATH}?first=${first}`
},
{
accountId
}
{}
)
await expect(validateListMiddleware(ctx, next)).resolves.toBeUndefined()
expect(next).toHaveBeenCalled()
Expand All @@ -114,9 +89,7 @@ describe('OpenAPI Validator', (): void => {
headers: { Accept: 'application/json' },
url: `${PATH}?first=NaN`
},
{
accountId
}
{}
)
await expect(validateListMiddleware(ctx, next)).rejects.toMatchObject({
status: 400,
Expand All @@ -136,9 +109,7 @@ describe('OpenAPI Validator', (): void => {
{
headers
},
{
accountId
}
{}
)
await expect(validatePostMiddleware(ctx, next)).rejects.toMatchObject({
status,
Expand Down Expand Up @@ -167,9 +138,7 @@ describe('OpenAPI Validator', (): void => {
'Content-Type': 'application/json'
}
},
{
accountId
}
{}
)
ctx.request.body = body
await expect(validatePostMiddleware(ctx, next)).rejects.toMatchObject({
Expand All @@ -187,9 +156,7 @@ describe('OpenAPI Validator', (): void => {
Accept: 'application/json'
}
},
{
accountId
}
{}
)
const next = jest.fn().mockImplementation(() => {
expect(ctx.request.query).toEqual({
Expand Down Expand Up @@ -228,9 +195,7 @@ describe('OpenAPI Validator', (): void => {
'Content-Type': 'application/json'
}
},
{
accountId
}
{}
)
ctx.request.body = {}
const next = jest.fn().mockImplementation(() => {
Expand Down

0 comments on commit 3fd4cbf

Please sign in to comment.