1
0
Fork 0
mirror of synced 2024-07-20 05:35:58 +12:00

Refactor tests to TS

This commit is contained in:
Adria Navarro 2023-08-21 16:57:00 +03:00
parent e5e1be4dd6
commit edb8cd6330

View file

@ -1,5 +1,7 @@
const { roles } = require("@budibase/backend-core")
const setup = require("./utilities")
import { roles } from "@budibase/backend-core"
import { Document, Row, Table } from "@budibase/types"
import * as setup from "./utilities"
const { basicRow } = setup.structures
const { BUILTIN_ROLE_IDS } = roles
@ -9,18 +11,18 @@ const STD_ROLE_ID = BUILTIN_ROLE_IDS.PUBLIC
describe("/permission", () => {
let request = setup.getRequest()
let config = setup.getConfig()
let table
let perms
let row
let table: Table & { _id: string }
let perms: Document[]
let row: Row
afterAll(setup.afterAll)
beforeAll(async () => {
await config.init()
})
beforeEach(async () => {
table = await config.createTable()
table = (await config.createTable()) as typeof table
row = await config.createRow()
perms = await config.addPermission(STD_ROLE_ID, table._id)
})
@ -124,7 +126,9 @@ describe("/permission", () => {
.expect("Content-Type", /json/)
.expect(200)
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.permissions).toBeDefined()
expect(publicPerm.name).toBeDefined()