-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.test.js
51 lines (43 loc) · 1.39 KB
/
index.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
import { describe, expect, it } from "vitest";
import { parseIgnored } from "./index";
describe("parseIgnored", () => {
it.each(["", null, undefined, "\r\n", "\n", "#", "#file"])(
"doesn't ignore when no patterns to ignore provided (%s)",
input => {
// when
const isIgnored = parseIgnored(input);
// then
expect(isIgnored("file")).toBe(false);
}
);
it("ignores ordinary patterns", () => {
// when
const isIgnored = parseIgnored(
"**/src/integration/**\n**/src/test/**\n**/src/testFixtures/**"
);
// then
expect(isIgnored("file")).toBe(false);
expect(isIgnored("src/test/file")).toBe(true);
expect(isIgnored("codebase/src/testFixtures/file")).toBe(true);
});
it.each([null, undefined, "/dev/null"])(
"ignores some patterns by default (%s)",
alwaysIgnoredInput => {
// when
const isIgnored = parseIgnored(
"**/src/integration/**\n**/src/test/**\n**/src/testFixtures/**"
);
// then
expect(isIgnored(alwaysIgnoredInput)).toBe(true);
}
);
it("accepts negated patterns", () => {
// when
const isIgnored = parseIgnored(".*\n!.gitignore\nyarn.lock\ngenerated/**");
// then
expect(isIgnored(".git")).toBe(true);
expect(isIgnored(".gitignore")).toBe(false);
expect(isIgnored("yarn.lock")).toBe(true);
expect(isIgnored("generated/source")).toBe(true);
});
});