-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
assert-arg-order.js
75 lines (71 loc) · 2.18 KB
/
assert-arg-order.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
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require('../../../lib/rules/assert-arg-order');
const RuleTester = require('eslint').RuleTester;
const { ERROR_MESSAGE } = rule;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2015,
sourceType: 'module'
}
});
ruleTester.run('assert-arg-order', rule, {
valid: [
{
code: "myFunction(true, 'My string.');"
},
{
code: "Ember.myFunction(true, 'My string.');"
},
{
code: "OtherClass.assert(true, 'My string.');"
},
{
code: "assert('My description.');"
},
{
code: "Ember.assert('My description.');"
},
{
code: "assert('My description.', true);"
},
{
code: "Ember.assert('My description.', true);"
},
{
code: "const CONDITION = true; assert('My description.', CONDITION);"
},
{
code: "const DESCRIPTION = 'description'; assert(DESCRIPTION, true);"
},
{
code: "const DESCRIPTION = 'description'; const CONDITION = true; assert(DESCRIPTION, CONDITION);"
}
],
invalid: [
{
code: "assert(true, 'My description.');",
errors: [{ message: ERROR_MESSAGE, type: 'CallExpression' }]
},
{
code: "Ember.assert(true, 'My description.');",
errors: [{ message: ERROR_MESSAGE, type: 'CallExpression' }]
},
{
code: 'assert(true, `My ${123} description.`);', // eslint-disable-line no-template-curly-in-string
errors: [{ message: ERROR_MESSAGE, type: 'CallExpression' }]
},
{
code: "const CONDITION = true; assert(CONDITION, 'My description.');",
errors: [{ message: ERROR_MESSAGE, type: 'CallExpression' }]
},
{
code: 'const CONDITION = true; assert(CONDITION, `My ${123} description.`);', // eslint-disable-line no-template-curly-in-string
errors: [{ message: ERROR_MESSAGE, type: 'CallExpression' }]
}
]
});