This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
test.js
130 lines (117 loc) · 3.41 KB
/
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
119
120
121
122
123
124
125
126
127
128
129
130
'use strict'
const exec = require('child_process').exec
const assert = require('assert')
it('🎉 Es Check should pass when checking an array of es5 files as es5', (done) => {
exec('node index.js es5 ./tests/es5.js ./tests/es5-2.js', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
})
})
it('🎉 Es Check should pass when checking a file with a hash bang', (done) => {
exec('node index.js es6 index.js --allow-hash-bang', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
})
})
it('👌 Es Check should fail when checking an array of es6 files as es5', (done) => {
exec('node index.js es5 ./tests/es6.js ./tests/es6-2.js', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('🎉 Es Check should pass when checking a glob of es6 files ', (done) => {
exec('node index.js es6 "./tests/*.js"', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
})
})
it('👌 Es Check fails when give an invalid version', (done) => {
exec('node index.js foo "./tests/*.js"', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('👌 Es Check should fail when checking a glob of es5 files', (done) => {
exec('node index.js es5 ./tests/*.js', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('👌 Es Check should fail when given a glob that matches no files', (done) => {
exec('node index.js es5 ./tests/es5.js foo-bar.js', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('👌 Es Check should fail when given a glob that matches files and a glob that does not', (done) => {
exec('node index.js es5 foo-bar.js', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('👌 Es Check should fail when checking a glob of es6 modules without --module flag', (done) => {
exec('node index.js es6 ./tests/modules/*.js', (err, stdout, stderr) => {
assert(err)
console.log(stdout)
done()
})
})
it('🎉 Es Check should pass when checking a glob of es6 modules using the --module flag', (done) => {
exec('node index.js es6 ./tests/modules/*.js --module', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
})
})
it('👌 Es Check should read from an .escheckrc file for config', (done) => {
exec('node index.js', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
})
})
it('👌 Es Check skips versions included in the not flag', (done) => {
exec('node index.js es6 ./tests/*/*.js --module --not=skipped,passed', (err, stdout, stderr) => {
if (err) {
console.error(err.stack)
console.error(stdout.toString())
console.error(stderr.toString())
done(err)
return
}
done()
});
});