forked from denolib/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathignore_test.ts
82 lines (76 loc) · 1.63 KB
/
ignore_test.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2020 denolib maintainers. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { test, runIfMain } from "https://deno.land/std/testing/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { parse } from "./ignore.ts";
const testCases = [
{
input: `# this is a comment
node_modules
`,
output: new Set(["node_modules"])
},
{
input: ` # invalid comment
`,
output: new Set([" # invalid comment"])
},
{
input: `
node_modules
package.json
`,
output: new Set(["node_modules", "package.json"])
},
{
input: `
node_modules
package.json
`,
output: new Set([" node_modules", " package.json"])
},
{
input: `*.orig
*.pyc
*.swp
/.idea/
/.vscode/
gclient_config.py_entries
/gh-pages/
/target/
# Files that help ensure VSCode can work but we don't want checked into the
# repo
/node_modules
/tsconfig.json
# We use something stronger than lockfiles, we have all NPM modules stored in a
# git. We do not download from NPM during build.
# https://github.com/denoland/deno_third_party
yarn.lock
# yarn creates this in error.
tools/node_modules/
`,
output: new Set([
"*.orig",
"*.pyc",
"*.swp",
"/.idea/",
"/.vscode/",
"gclient_config.py_entries",
"/gh-pages/",
"/target/",
"/node_modules",
"/tsconfig.json",
"yarn.lock",
"tools/node_modules/"
])
}
];
test({
name: "[encoding.ignore] basic",
fn(): void {
for (const { input, output } of testCases) {
assertEquals(parse(input), output);
}
}
});
runIfMain(import.meta);