-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathinvalid-deprecations.test.mjs
More file actions
107 lines (102 loc) · 2.04 KB
/
invalid-deprecations.test.mjs
File metadata and controls
107 lines (102 loc) · 2.04 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { describe, it } from 'node:test';
import dedent from 'dedent';
import { testRule } from './utils.mjs';
import invalidDeprecations from '../invalid-deprecations.mjs';
const TYPE = 'Type: [...]';
const CHANGES = dedent`
<!-- YAML
changes:
-->
`;
const BODY = TYPE + '\n' + CHANGES;
const testCases = [
{
name: 'in order deprecations',
input: dedent`
## DEP0001:
${BODY}
## DEP0002:
${BODY}
`,
expected: [],
},
{
name: 'out of order deprecations',
input: dedent`
## DEP0001:
${BODY}
## DEP0003:
${BODY}
`,
expected: [
'Deprecation codes are out of order. Expected DEP0002, saw "DEP0003"',
],
},
{
name: 'skipped deprecations',
input: dedent`
## DEP0001:
${BODY}
<!-- md-lint skip-deprecation DEP0002 -->
## DEP0003:
${BODY}
`,
expected: [],
},
{
name: 'out of order skipped deprecations',
input: dedent`
## DEP0001:
${BODY}
<!-- md-lint skip-deprecation DEP0004 -->
## DEP0003:
${BODY}
`,
expected: [
'Deprecation codes are out of order. Expected DEP0002, saw "DEP0004"',
],
},
{
name: 'not enough skipped deprecations',
input: dedent`
## DEP0001:
${BODY}
<!-- md-lint skip-deprecation DEP0002 -->
## DEP0004:
${BODY}
`,
expected: [
'Deprecation codes are out of order. Expected DEP0003, saw "DEP0004"',
],
},
{
name: 'no type',
input: dedent`
## DEP0001:
some text
${CHANGES}
`,
expected: ['Deprecation "DEP0001" is missing a "Type"'],
},
{
name: 'no changes',
input: dedent`
## DEP0001:
${TYPE}
`,
expected: ['Deprecation "DEP0001" is missing changes'],
},
];
describe('invalid-deprecations', () => {
for (const { name, input, expected, options } of testCases) {
it(name, () =>
testRule(
invalidDeprecations,
input,
expected,
{ stem: 'deprecations' },
options
)
);
}
});