generated from alphane/template
Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { type RouteLocationNormalized } from "vue-router"
|
||||
|
||||
import authorizationGuard from "@/utils/authorization-guards/authorization-guard"
|
||||
|
||||
describe("web/src/utils/authorization-guards/authorization-guard.ts", () => {
|
||||
describe("authorizationGuard", () => {
|
||||
test("when there are no guards, returns true", async () => {
|
||||
const to = {
|
||||
meta: {},
|
||||
} as unknown as RouteLocationNormalized
|
||||
|
||||
const result = await authorizationGuard(to)
|
||||
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("when all guards return true, returns true", async () => {
|
||||
const to = {
|
||||
meta: {
|
||||
guards: [() => true, () => true, () => true],
|
||||
},
|
||||
} as unknown as RouteLocationNormalized
|
||||
|
||||
const result = await authorizationGuard(to)
|
||||
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("when any guard returns false, returns false", async () => {
|
||||
const to = {
|
||||
meta: {
|
||||
guards: [() => true, () => false, () => true],
|
||||
},
|
||||
} as unknown as RouteLocationNormalized
|
||||
|
||||
const result = await authorizationGuard(to)
|
||||
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user