-
Notifications
You must be signed in to change notification settings - Fork 1
/
plan-lint.test.js
63 lines (55 loc) · 1.04 KB
/
plan-lint.test.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
const test = require('ava');
const sinon = require('sinon');
const {lint} = require('./plan-lint');
test('lint', t => {
const ruleVisitor = {
start: sinon.spy(),
implementation: sinon.spy(),
end: sinon.spy()
};
const rule = {
id: 'test',
create: () => ruleVisitor
};
lint([{
id: 'a',
interface: 'a',
dependencies: []
}, {
id: 'b',
interface: 'b',
dependencies: []
}], {
rules: [rule]
});
t.true(ruleVisitor.start.calledOnce);
t.true(ruleVisitor.end.calledOnce);
t.is(ruleVisitor.implementation.callCount, 2);
});
test('default rules against missing', t => {
const a = {
id: 'a',
interface: 'a',
dependencies: ['b']
};
const errors = lint([a]);
t.true(errors.length > 0);
});
test('default rules against empty', t => {
const errors = lint([], {
target: 'a'
});
t.true(errors.length > 0);
});
test('no-undef', t => {
const a = {
id: 'a',
interface: 'a',
dependencies: ['b']
};
const errors = lint([a], {
rules: ['no-undef']
});
t.true(errors.length > 0);
t.is(errors[0].ruleId, 'no-undef');
});