Skip to content

Commit fffca51

Browse files
committed
Add test to check no outputs are printed for empty reports
Fixes #39
1 parent b9c31a5 commit fffca51

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

test/fixtures/validCSS.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.foo {
1+
.is-foo {
22
color: red;
33
}

test/main.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ describe('gulp-csslint', function() {
250250
stream.write(file);
251251
stream.end();
252252
});
253+
});
253254

255+
describe('cssLintPlugin.reporter()', function() {
254256
it('should support built-in CSSLint formatters', sinon.test(function(done) {
255257
var a = 0;
256258

@@ -284,5 +286,39 @@ describe('gulp-csslint', function() {
284286
lintStream.write(file);
285287
lintStream.end();
286288
}));
289+
290+
it('should not print empty output by built-in CSSLint formatters', sinon.test(function(done) {
291+
var a = 0;
292+
293+
var file = getFile('fixtures/validCSS.css');
294+
295+
var lintStream = cssLintPlugin();
296+
var reporterStream = cssLintPlugin.reporter('text');
297+
298+
sinon.stub(gutil, 'log');
299+
300+
reporterStream.on('data', function() {
301+
++a;
302+
});
303+
lintStream.on('data', function(newFile) {
304+
should.exist(newFile.csslint.success);
305+
newFile.csslint.success.should.equal(true);
306+
reporterStream.write(newFile);
307+
});
308+
lintStream.once('end', function() {
309+
reporterStream.end();
310+
});
311+
312+
reporterStream.once('end', function() {
313+
a.should.equal(1);
314+
sinon.assert.callCount(gutil.log, 0);
315+
316+
gutil.log.restore();
317+
done();
318+
});
319+
320+
lintStream.write(file);
321+
lintStream.end();
322+
}));
287323
});
288324
});

0 commit comments

Comments
 (0)