forked from eslint-community/eslint-plugin-eslint-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-case-property-ordering.js
151 lines (145 loc) · 4.26 KB
/
test-case-property-ordering.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* @fileoverview Requires the properties of a test case to be placed in a consistent order.
* @author 薛定谔的猫<[email protected]>
*/
'use strict';
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const rule = require('../../../lib/rules/test-case-property-ordering');
const RuleTester = require('eslint').RuleTester;
// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------
const ruleTester = new RuleTester();
ruleTester.run('test-case-property-ordering', rule, {
valid: [
`
new RuleTester().run('foo', bar, {
valid: [
'foo',
RuleTester.only('foo'),
]
});
`,
`
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", output: "bar", options: ["baz"], },
]
});
`,
`
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo",output: "bar",options: ["baz"],env: { es6: true }, },
]
});
`,
`
new RuleTester().run('foo', bar, {
valid: [
{ filename: '', code: '', output: '', options: '', parser: '', parserOptions: '', globals: '', env: '', errors: '' },
]
});
`,
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", options: ["baz"], output: "bar", },
]
});
`,
options: [['code', 'errors', 'options', 'output', 'parserOptions']],
},
],
invalid: [
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", options: ["baz"], output: "bar", },
]
});
`,
output: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", output: "bar", options: ["baz"], },
]
});
`,
errors: [{ message: 'The properties of a test case should be placed in a consistent order: [code, output, options].' }],
},
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{ env: { es6: true }, code: "foo", output: "bar", options: ["baz"], },
]
});
`,
output: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", output: "bar", options: ["baz"], env: { es6: true }, },
]
});
`,
errors: [{ message: 'The properties of a test case should be placed in a consistent order: [code, output, options, env].' }],
},
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", env: { es6: true }, output: "bar", options: ["baz"], },
]
});
`,
output: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", output: "bar", options: ["baz"], env: { es6: true }, },
]
});
`,
errors: [{ message: 'The properties of a test case should be placed in a consistent order: [code, output, options, env].' }],
},
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", output: "bar", options: ["baz"], },
]
});
`,
output: `
new RuleTester().run('foo', bar, {
valid: [
{ code: "foo", options: ["baz"], output: "bar", },
]
});
`,
options: [['code', 'errors', 'options', 'output', 'parserOptions']],
errors: [{ message: 'The properties of a test case should be placed in a consistent order: [code, options, output].' }],
},
{
code: `
new RuleTester().run('foo', bar, {
valid: [
{\ncode: "foo",\noutput: "",\nerrors: ["baz"],\nparserOptions: "",\n},
]
});
`,
output: `
new RuleTester().run('foo', bar, {
valid: [
{\ncode: "foo",\noutput: "",\nparserOptions: "",\nerrors: ["baz"],\n},
]
});
`,
errors: [{ message: 'The properties of a test case should be placed in a consistent order: [code, output, parserOptions, errors].' }],
},
],
});