-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintegrationTests.js
157 lines (118 loc) · 4.28 KB
/
integrationTests.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
152
153
154
155
156
157
var spawn = require('child_process').spawn;
require('should');
describe('mdlint', function () {
describe('glob', function () {
describe('when all matched files pass linting', function () {
var logData = '';
var exitCode;
before(function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'glob', 'test/fixtures/goodsyntax.md']);
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function (code) {
exitCode = code;
done();
});
});
it('should not log the local markdown files that pass linting', function () {
logData.should.not.include('Markdown passed linting');
logData.should.not.include('test/fixtures/partials.md');
});
it('should log a success message', function () {
logData.should.not.include('Markdown passed linting');
});
it('should have an exit code of 0', function () {
exitCode.should.eql(0);
});
});
describe('when one or more matched file(s) fail linting', function () {
var logData = '';
var exitCode;
before(function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'glob', 'test/fixtures/*.md']);
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function (code) {
exitCode = code;
done();
});
});
it('should log the local markdown files that failed linting', function () {
logData.should.not.include('Markdown passed linting');
logData.should.not.include('test/fixtures/goodsyntax.md');
logData.should.not.include('test/fixtures/partials.md');
logData.should.include('Markdown failed linting');
logData.should.include('test/fixtures/syntaxerror.md');
});
it('should have an exit code of 1', function () {
exitCode.should.eql(1);
});
});
});
if (process.env.NODE_ENV !== 'dev') {
describe('repo', function () {
it('should lint a README from a GitHub repo', function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'repo', 'ChrisWren/mdlint', '-v']);
var logData = '';
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function () {
logData.should.include('Markdown passed linting');
done();
});
});
});
}
describe('when run with the -v flag', function () {
var logData = '';
var exitCode;
before(function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'glob', 'test/fixtures/*.md', '-v']);
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function (code) {
exitCode = code;
done();
});
});
it('should log the result of all markdown being linted', function () {
logData.should.include('Markdown passed linting');
logData.should.include('test/fixtures/goodsyntax.md');
logData.should.include('test/fixtures/partials.md');
logData.should.include('Markdown failed linting');
logData.should.include('test/fixtures/syntaxerror.md');
});
});
if (process.env.NODE_ENV !== 'dev') {
describe('user', function () {
it('should lint all READMEs from a users\'s GitHub repos', function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'user', 'mishalshah', '-v']);
var logData = '';
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function () {
logData.should.include('Markdown passed linting');
done();
});
});
});
describe('query', function () {
it('should lint READMEs from repos returned by a GitHub query', function (done) {
var lintProcess = spawn('node', ['./bin/mdlint', 'query', 'grunt-pages', '-v']);
var logData = '';
lintProcess.stdout.on('data', function (data) {
logData += data;
});
lintProcess.on('close', function () {
logData.should.include('Markdown passed linting');
done();
});
});
});
}
});