summaryrefslogtreecommitdiff
path: root/std/prettier/ignore_test.ts
blob: 019cddc0e47bf682bbf0b5e9c95c9d7795bd90e0 (plain)
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
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { test, runIfMain } from "../testing/mod.ts";
import { assertEquals } from "../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);