removing tests
This commit is contained in:
parent
ada052e043
commit
df38368eaf
|
@ -1,60 +0,0 @@
|
||||||
import {
|
|
||||||
doesHaveBasePermission,
|
|
||||||
getBuiltinPermissionByID,
|
|
||||||
isPermissionLevelHigherThanRead,
|
|
||||||
PermissionLevel,
|
|
||||||
PermissionType,
|
|
||||||
} from "../permissions"
|
|
||||||
|
|
||||||
xdescribe("getBuiltinPermissionByID", () => {
|
|
||||||
it("should return the correct permission object", () => {
|
|
||||||
const id = "123"
|
|
||||||
const permission = { _id: id, name: "Test Permission" }
|
|
||||||
expect(getBuiltinPermissionByID(id)).toEqual(permission)
|
|
||||||
expect(getBuiltinPermissionByID("456")).toBeUndefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
xdescribe("doesHaveBasePermission", () => {
|
|
||||||
it("should return true if base permission has the required level", () => {
|
|
||||||
const permType = PermissionType.APP
|
|
||||||
const permLevel = PermissionLevel.READ
|
|
||||||
const rolesHierarchy = [
|
|
||||||
{ roleId: "role1", permissionId: "permission1" },
|
|
||||||
{ roleId: "role2", permissionId: "permission2" },
|
|
||||||
]
|
|
||||||
expect(
|
|
||||||
doesHaveBasePermission(
|
|
||||||
permType,
|
|
||||||
permLevel,
|
|
||||||
rolesHierarchy
|
|
||||||
)
|
|
||||||
).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should return false if base permission does not have the required level", () => {
|
|
||||||
const permType = PermissionType.APP
|
|
||||||
const permLevel = PermissionLevel.READ
|
|
||||||
const rolesHierarchy = [
|
|
||||||
{ roleId: "role1", permissionId: "permission1" },
|
|
||||||
{ roleId: "role2", permissionId: "permission2" },
|
|
||||||
]
|
|
||||||
expect(
|
|
||||||
doesHaveBasePermission(
|
|
||||||
permType,
|
|
||||||
permLevel,
|
|
||||||
rolesHierarchy
|
|
||||||
)
|
|
||||||
).toBeFalsy()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
xdescribe("isPermissionLevelHigherThanRead", () => {
|
|
||||||
it("should return true if level is higher than read", () => {
|
|
||||||
expect(isPermissionLevelHigherThanRead(PermissionLevel.WRITE)).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should return false if level is read or lower", () => {
|
|
||||||
expect(isPermissionLevelHigherThanRead(PermissionLevel.READ)).toBeFalsy()
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { PermissionLevel } from "../permissions"
|
|
||||||
import { Role, getBuiltinRoles } from "../roles"
|
|
||||||
|
|
||||||
xdescribe("Role", () => {
|
|
||||||
describe("constructor", () => {
|
|
||||||
test("it should initialize _id, name, and permissionId", () => {
|
|
||||||
const role = new Role("my-role", "My Role", PermissionLevel.READ)
|
|
||||||
expect(role._id).toEqual("my-role")
|
|
||||||
expect(role.name).toEqual("My Role")
|
|
||||||
expect(role.permissionId).toEqual(PermissionLevel.READ)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("addInheritance", () => {
|
|
||||||
test("it should add the inheritance property to the role", () => {
|
|
||||||
const role = new Role("my-role", "My Role", PermissionLevel.READ)
|
|
||||||
const newRole = role.addInheritance("other-role")
|
|
||||||
expect(newRole).toEqual(role)
|
|
||||||
expect(role.inherits).toEqual("other-role")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("getBuiltinRoles", () => {
|
|
||||||
test("it should return an object of builtin roles", () => {
|
|
||||||
const builtinRoles = getBuiltinRoles()
|
|
||||||
expect(builtinRoles).toHaveProperty("ADMIN")
|
|
||||||
expect(builtinRoles).toHaveProperty("POWER")
|
|
||||||
expect(builtinRoles).toHaveProperty("BASIC")
|
|
||||||
expect(builtinRoles).toHaveProperty("PUBLIC")
|
|
||||||
expect(builtinRoles).not.toHaveProperty("BUILDER")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
Reference in New Issue