More tests
This commit is contained in:
parent
525052ce7e
commit
d8df917772
|
@ -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")
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue