mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix Role creation method and permission checks in tests
This commit is contained in:
@@ -11,7 +11,7 @@ function createGuard(
|
||||
) {
|
||||
const _roles = roles
|
||||
? objectTransform(roles, ({ permissions = [], is_default, implicit_allow }, name) => {
|
||||
return Role.create({ name, permissions, is_default, implicit_allow });
|
||||
return Role.create(name, { permissions, is_default, implicit_allow });
|
||||
})
|
||||
: {};
|
||||
const _permissions = permissionNames.map((name) => new Permission(name));
|
||||
|
||||
@@ -252,7 +252,7 @@ describe("permission middleware", () => {
|
||||
|
||||
it("allows if user has (plain) role", async () => {
|
||||
const p = new Permission("test");
|
||||
const r = Role.create({ name: "test", permissions: [p.name] });
|
||||
const r = Role.create("test", { permissions: [p.name] });
|
||||
const hono = makeApp([p], [r])
|
||||
.use(async (c, next) => {
|
||||
// @ts-expect-error
|
||||
@@ -512,7 +512,7 @@ describe("Role", () => {
|
||||
true,
|
||||
);
|
||||
const json = JSON.parse(JSON.stringify(r.toJSON()));
|
||||
const r2 = Role.create(json);
|
||||
const r2 = Role.create(p.name, json);
|
||||
expect(r2.toJSON()).toEqual(r.toJSON());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user