Refactor tests to TS
This commit is contained in:
parent
e5e1be4dd6
commit
edb8cd6330
|
@ -1,5 +1,7 @@
|
||||||
const { roles } = require("@budibase/backend-core")
|
import { roles } from "@budibase/backend-core"
|
||||||
const setup = require("./utilities")
|
import { Document, Row, Table } from "@budibase/types"
|
||||||
|
import * as setup from "./utilities"
|
||||||
|
|
||||||
const { basicRow } = setup.structures
|
const { basicRow } = setup.structures
|
||||||
const { BUILTIN_ROLE_IDS } = roles
|
const { BUILTIN_ROLE_IDS } = roles
|
||||||
|
|
||||||
|
@ -9,18 +11,18 @@ const STD_ROLE_ID = BUILTIN_ROLE_IDS.PUBLIC
|
||||||
describe("/permission", () => {
|
describe("/permission", () => {
|
||||||
let request = setup.getRequest()
|
let request = setup.getRequest()
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
let table
|
let table: Table & { _id: string }
|
||||||
let perms
|
let perms: Document[]
|
||||||
let row
|
let row: Row
|
||||||
|
|
||||||
afterAll(setup.afterAll)
|
afterAll(setup.afterAll)
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await config.init()
|
await config.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
table = await config.createTable()
|
table = (await config.createTable()) as typeof table
|
||||||
row = await config.createRow()
|
row = await config.createRow()
|
||||||
perms = await config.addPermission(STD_ROLE_ID, table._id)
|
perms = await config.addPermission(STD_ROLE_ID, table._id)
|
||||||
})
|
})
|
||||||
|
@ -124,7 +126,9 @@ describe("/permission", () => {
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
expect(Array.isArray(res.body)).toEqual(true)
|
expect(Array.isArray(res.body)).toEqual(true)
|
||||||
const publicPerm = res.body.find(perm => perm._id === "public")
|
const publicPerm = res.body.find(
|
||||||
|
(perm: Document) => perm._id === "public"
|
||||||
|
)
|
||||||
expect(publicPerm).toBeDefined()
|
expect(publicPerm).toBeDefined()
|
||||||
expect(publicPerm.permissions).toBeDefined()
|
expect(publicPerm.permissions).toBeDefined()
|
||||||
expect(publicPerm.name).toBeDefined()
|
expect(publicPerm.name).toBeDefined()
|
Loading…
Reference in New Issue