-
Notifications
You must be signed in to change notification settings - Fork 4
/
segment-public-api.test.js
57 lines (49 loc) · 2.03 KB
/
segment-public-api.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
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("Segment PublicAPI:", () => {
it("Should lint Segment PublicAPI boundaries with errors.", async () => {
const report = await eslint.lintText(`
export { SubmitButton } from "./ui/button";
export { SmthForm } from "./ui/form";
export * from "./model/actions";
export { selectSmthById } from "./model/selectors";
`,
{ filePath: "src/features/smth/index.ts" });
assert.strictEqual(report[0].errorCount, 4);
});
it("Should lint Segment PublicAPI boundaries without errors.", async () => {
const report = await eslint.lintText(`
export { SubmitButton, SmthForm } from "./ui";
export * from "./model";
export { selectSmthById, selectSmthByName } from "./model";
`, { filePath: "src/features/smth/index.ts" });
assert.strictEqual(report[0].errorCount, 0);
});
describe("Exclusive Segments Public API for shared layer:", () => {
it("Should lint with errors.", async () => {
const report = await eslint.lintText(`
import { Button } from "shared/ui/button/button";
import { Date } from "shared/lib/date/date";
`,
{ filePath: "src/features/smth/index.ts" });
assert.strictEqual(report[0].errorCount, 2);
});
it("Should lint without errors.", async () => {
const report = await eslint.lintText(`
import { Button } from "shared/ui/button";
import { SexyButton } from "shared/ui";
import { Parser } from "shared/lib";
import { Date } from "shared/lib/date";
`, { filePath: "src/features/smth/index.ts" });
assert.strictEqual(report[0].errorCount, 0);
});
});
});