-
Notifications
You must be signed in to change notification settings - Fork 5
/
validation-test.js
118 lines (99 loc) · 2.18 KB
/
validation-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
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
var write = require('nodeunit').testCase;
var Codesurgeon = require('../lib/codesurgeon').Codesurgeon;
var vm = require('vm');
var fs = require('fs');
module.exports = write({
setUp: function (test) {
if (typeof test === 'function') {
test();
}
else {
test.done();
}
},
tearDown: function (test) {
if (typeof test === 'function') {
test();
}
else {
test.done();
}
},
'1. Lint fail (intentionally).': function (test) {
var surgeon = new Codesurgeon;
surgeon
.configure({ quiet: true })
.read(__dirname + '/fixture1.js')
.extract(
'NODEJITSU.B',
'NODEJITSU.B.prototype.p'
)
.lint()
;
test.ok(true, 'Test finished.');
test.expect(1);
test.done();
},
'2. Lint succeed.': function (test) {
var surgeon = new Codesurgeon;
surgeon
.configure({ quiet: true })
.read(__dirname + '/fixture1.js')
.extract(
'NODEJITSU.B',
'NODEJITSU.B.prototype.q'
)
.lint()
;
test.ok(true, 'Test finished.');
test.expect(1);
test.done();
},
'3. Hint fail (intentionally).': function (test) {
var surgeon = new Codesurgeon;
surgeon
.configure({ quiet: true })
.read(__dirname + '/fixture1.js')
.extract(
'NODEJITSU.B',
'NODEJITSU.B.prototype.p'
)
.hint()
;
test.ok(true, 'Test finished.');
test.expect(1);
test.done();
},
'4. Hint succeed.': function (test) {
var surgeon = new Codesurgeon;
surgeon
.configure({ quiet: true })
.read(__dirname + '/fixture1.js')
.extract(
'NODEJITSU.B',
'NODEJITSU.B.prototype.q'
)
.hint()
;
test.ok(true, 'Test finished.');
test.expect(1);
test.done();
},
'5. Find prerequisites.': function (test) {
var surgeon = new Codesurgeon;
var sandbox = {
exports: {}
};
surgeon
.configure({
quiet: true,
package: __dirname + '/../package.json'
})
.read(__dirname + '/fixture2.js')
.extract()
.validate()
;
test.expect(0);
test.done();
}
});