Page MenuHomeSealhub

not.test.js
No OneTemporary

not.test.js

const assert = require("assert");
const Op = require("sequelize").Op;
const anyone = require("./anyone.js");
const noone = require("./noone.js");
const or = require("./or.js");
const and = require("./and.js");
const not = require("./not.js");
const AccessStrategy = require("./access-strategy.js");
describe("access-strategy", () => {
describe("not", () => {
describe("constructor", () => {
it("should throw an error if constructed without param", () =>
assert.throws(() => not()));
it("should throw an error if constructed with param that is not an AccessStrategy", () =>
assert.throws(() => not("anyone")));
});
describe("checkItem", () => {
it("should allow access when given access strategy denies it", async () =>
assert((await not(noone).checkItem()).allowed));
it("should deny access when given access strategy allows it", async () =>
assert((await not(anyone).checkItem()).allowed === false));
it("should work with compound access strategies", async () =>
assert(
(await not(and(anyone, or(noone, anyone))).checkItem()).allowed ===
false
));
});
describe("filterModelQuery", () => {
it("should negate the model query of given access strategy", async () =>
assert.deepEqual(
(await not(noone).filterModelQuery())[Op.not],
await AccessStrategy.QueryFilters.DenyAll()
));
});
});
});

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 27, 19:21 (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
619457
Default Alt Text
not.test.js (1 KB)

Event Timeline