More tests

This commit is contained in:
Adria Navarro 2023-07-31 14:08:31 +02:00
parent 525052ce7e
commit d8df917772
2 changed files with 16 additions and 1 deletions

View File

@ -160,4 +160,15 @@ describe("trimViewRowInfo middleware", () => {
expect(config.throw).toBeCalledTimes(1)
expect(config.throw).toBeCalledWith(400, "_viewId is required")
})
it("it should throw an error if no viewid is provided on the parameters", async () => {
const data = getRandomData()
await config.executeMiddleware(undefined as any, {
_viewId: viewId,
...data,
})
expect(config.throw).toBeCalledTimes(1)
expect(config.throw).toBeCalledWith(400, "viewId path is required")
})
})

View File

@ -8,7 +8,11 @@ export default async (ctx: Ctx<Row>, next: Next) => {
const { body } = ctx.request
const { _viewId: viewId } = body
if (!viewId) {
ctx.throw(400, "_viewId is required")
return ctx.throw(400, "_viewId is required")
}
if (!ctx.params.viewId) {
return ctx.throw(400, "viewId path is required")
}
const { tableId } = utils.extractViewInfoFromID(ctx.params.viewId)