2021-03-12 16:32:16 +01:00
|
|
|
const setup = require("./utilities")
|
|
|
|
|
|
|
|
describe("test the delete row action", () => {
|
2022-03-22 01:23:22 +01:00
|
|
|
let table: any
|
|
|
|
let row: any
|
|
|
|
let inputs: any
|
2021-03-12 16:32:16 +01:00
|
|
|
let config = setup.getConfig()
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
await config.init()
|
|
|
|
table = await config.createTable()
|
|
|
|
row = await config.createRow()
|
|
|
|
inputs = {
|
|
|
|
tableId: table._id,
|
|
|
|
id: row._id,
|
|
|
|
revision: row._rev,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(setup.afterAll)
|
|
|
|
|
|
|
|
it("should be able to run the action", async () => {
|
|
|
|
const res = await setup.runStep(setup.actions.DELETE_ROW.stepId, inputs)
|
|
|
|
expect(res.success).toEqual(true)
|
|
|
|
expect(res.response).toBeDefined()
|
|
|
|
expect(res.row._id).toEqual(row._id)
|
|
|
|
let error
|
|
|
|
try {
|
2022-04-21 15:56:14 +02:00
|
|
|
await config.getRow(table._id, res.row._id)
|
2021-03-12 16:32:16 +01:00
|
|
|
} catch (err) {
|
|
|
|
error = err
|
|
|
|
}
|
|
|
|
expect(error).toBeDefined()
|
|
|
|
})
|
|
|
|
|
|
|
|
it("check usage quota attempts", async () => {
|
2021-03-24 19:21:23 +01:00
|
|
|
await setup.runInProd(async () => {
|
|
|
|
await setup.runStep(setup.actions.DELETE_ROW.stepId, inputs)
|
|
|
|
})
|
2021-03-12 16:32:16 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it("should check invalid inputs return an error", async () => {
|
|
|
|
const res = await setup.runStep(setup.actions.DELETE_ROW.stepId, {})
|
|
|
|
expect(res.success).toEqual(false)
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should return an error when table doesn't exist", async () => {
|
|
|
|
const res = await setup.runStep(setup.actions.DELETE_ROW.stepId, {
|
|
|
|
tableId: "invalid",
|
|
|
|
id: "invalid",
|
|
|
|
revision: "invalid",
|
|
|
|
})
|
|
|
|
expect(res.success).toEqual(false)
|
|
|
|
})
|
|
|
|
})
|