-
Notifications
You must be signed in to change notification settings - Fork 4
/
slices.test.js
67 lines (52 loc) · 2.13 KB
/
slices.test.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { ESLint } = require("eslint");
const assert = require("assert");
const { configLib } = require("../../utils");
const cfg = require(".");
const eslint = new ESLint({
useEslintrc: false,
baseConfig: configLib.setParser(
configLib.mockImports(cfg)
),
});
describe("Import boundaries between slices and layers", () => {
it("should lint with cross-import errors between pages.", async () => {
const wrongImports = [
`import { getAuthCtx } from "pages/logout";`,
`import { UserAvatar } from "pages/auth";`,
];
const report = await eslint.lintText(wrongImports.join("\n"), {
filePath: "src/pages/map/index.js",
});
assert.strictEqual(report[0].errorCount, wrongImports.length);
});
it("should lint with cross-import errors between widgets.", async () => {
const wrongImports = [
`import { HeaderTitle } from "widgets/header";`,
`import { Links } from "widgets/footer";`,
];
const report = await eslint.lintText(wrongImports.join("\n"), {
filePath: "src/widgets/mock/index.js",
});
assert.strictEqual(report[0].errorCount, wrongImports.length);
});
it("should lint with cross-import errors between features.", async () => {
const wrongImports = [
`import { getAuthCtx } from "features/logout";`,
`import { UserAvatar } from "features/viewer-picker";`,
];
const report = await eslint.lintText(wrongImports.join("\n"), {
filePath: "features/auth-form/index.js",
});
assert.strictEqual(report[0].errorCount, wrongImports.length);
});
it("should lint with cross-import errors between entities.", async () => {
const wrongImports = [
`import { LoginForm } from "features/login-form";`,
`import { Avatar } from "features/avatar";`,
];
const report = await eslint.lintText(wrongImports.join("\n"), {
filePath: "src/entities/mock/index.js",
});
assert.strictEqual(report[0].errorCount, wrongImports.length);
});
});