simpleScope.spec.js
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {
appendSimplePermissions,
SIMPLE_PERMISSION_IDS,
} from "./simpleScope";
describe("simple project permission scope", () => {
it("injects the migrated routes only when the development bypass is enabled", () => {
const source = [{ authId: "903", parentId: "1" }];
const result = appendSimplePermissions(source, {
nodeEnv: "development",
enabled: "true",
});
expect(result).not.toBe(source);
expect(result.map(item => item.authId)).toEqual(
expect.arrayContaining(SIMPLE_PERMISSION_IDS),
);
});
it("never injects permissions into a production build", () => {
const source = [{ authId: "903", parentId: "1" }];
expect(appendSimplePermissions(source, {
nodeEnv: "production",
enabled: "true",
})).toEqual(source);
});
it("keeps an existing backend permission only once", () => {
const source = [
{ authId: "904", parentId: "1" },
{ authId: "90412", parentId: "904" },
];
const result = appendSimplePermissions(source, {
nodeEnv: "test",
enabled: true,
});
expect(result.filter(item => item.authId === "90412")).toHaveLength(1);
});
});