Skip to content

Commit 8a6dee8

Browse files
committed
Put expected output in a separate file, rename test
1 parent 37294d7 commit 8a6dee8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

test/expected/checkstyle-xml.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><checkstyle><file name="test/fixtures/usingImportant.css"><error line="2" column="1" severity="warning" message="Bad naming: .mybox" source="net.csslint.OOCSS"/><error line="3" column="3" severity="warning" message="Use of !important" source="net.csslint.Disallow!important"/></file></checkstyle>

test/main.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ var getFile = function(filePath) {
1717
});
1818
};
1919

20+
var getContents = function(filePath) {
21+
filePath = 'test/'+filePath;
22+
return fs.readFileSync(filePath, 'utf8');
23+
};
24+
2025
describe('gulp-csslint', function() {
2126
describe('cssLintPlugin()', function() {
2227
it('should pass file through', function(done) {
@@ -246,10 +251,11 @@ describe('gulp-csslint', function() {
246251
stream.end();
247252
});
248253

249-
it('should use built-in formatter', sinon.test(function(done) {
254+
it('should support built-in CSSLint formatters', sinon.test(function(done) {
250255
var a = 0;
251256

252257
var file = getFile('fixtures/usingImportant.css');
258+
var expected = getContents('expected/checkstyle-xml.xml');
253259

254260
var lintStream = cssLintPlugin();
255261
var reporterStream = cssLintPlugin.reporter('checkstyle-xml');
@@ -268,11 +274,8 @@ describe('gulp-csslint', function() {
268274

269275
reporterStream.once('end', function() {
270276
a.should.equal(1);
271-
sinon.assert.calledOnce(gutil.log, 'asdasd');
272-
sinon.assert.calledWith(gutil.log, '<?xml version="1.0" encoding="utf-8"?><checkstyle><file ' +
273-
'name="test/fixtures/usingImportant.css"><error line="2" column="1" severity="warning" ' +
274-
'message="Bad naming: .mybox" source="net.csslint.OOCSS"/><error line="3" column="3" severity="warning" ' +
275-
'message="Use of !important" source="net.csslint.Disallow!important"/></file></checkstyle>');
277+
sinon.assert.calledOnce(gutil.log);
278+
sinon.assert.calledWith(gutil.log, expected);
276279

277280
gutil.log.restore();
278281
done();

0 commit comments

Comments
 (0)