1- /* global it, afterEach, beforeEach, describe, Promise */
1+ /* eslint-env node, mocha */
2+ /* eslint max-len: ["off"] */
23
34var assert = require ( 'assert' )
45var gutil = require ( 'gulp-util' )
@@ -45,6 +46,28 @@ it('should transform css with multiple processors', function (cb) {
4546
4647} )
4748
49+ it ( 'should not transform css with out any processor' , function ( cb ) {
50+
51+ var css = 'a { color: black }'
52+
53+ var stream = postcss ( function ( ) {
54+ return { }
55+ } )
56+
57+ stream . on ( 'data' , function ( file ) {
58+ var result = file . contents . toString ( 'utf8' )
59+ var target = css
60+ assert . equal ( result , target )
61+ cb ( )
62+ } )
63+
64+ stream . write ( new gutil . File ( {
65+ contents : new Buffer ( css )
66+ } ) )
67+
68+ stream . end ( )
69+
70+ } )
4871
4972it ( 'should correctly wrap postcss errors' , function ( cb ) {
5073
@@ -89,7 +112,7 @@ it('should respond with error on stream files', function (cb) {
89112 isStream : function ( ) { return true } ,
90113 isNull : function ( ) { return false } ,
91114 path : path . resolve ( 'testpath' )
92- } ;
115+ }
93116
94117 stream . write ( streamFile )
95118
@@ -163,27 +186,27 @@ describe('PostCSS Guidelines', function () {
163186 return this . source
164187 }
165188 this . toString = function ( ) {
166- var code = this . showSourceCode ( ) ;
189+ var code = this . showSourceCode ( )
167190 if ( code ) {
168- code = '\n\n' + code + '\n' ;
191+ code = '\n\n' + code + '\n'
169192 }
170- return this . name + ': ' + this . message + code ;
193+ return this . name + ': ' + this . message + code
171194 }
172195 }
173196 var postcssStub = {
174- use : function ( ) { }
175- , process : function ( ) { }
197+ use : function ( ) { } ,
198+ process : function ( ) { }
176199 }
177200 var postcssLoadConfigStub
178201 var postcss = proxyquire ( './index' , {
179202 postcss : function ( plugins ) {
180203 postcssStub . use ( plugins )
181204 return postcssStub
182- }
183- , 'postcss-load-config' : function ( ctx , configPath ) {
205+ } ,
206+ 'postcss-load-config' : function ( ctx , configPath ) {
184207 return postcssLoadConfigStub ( ctx , configPath )
185- }
186- , 'vinyl-sourcemaps-apply' : function ( ) {
208+ } ,
209+ 'vinyl-sourcemaps-apply' : function ( ) {
187210 return { }
188211 }
189212 } )
@@ -203,8 +226,8 @@ describe('PostCSS Guidelines', function () {
203226 var stream = postcss ( [ doubler ] )
204227 var cssPath = __dirname + '/src/fixture.css'
205228 postcssStub . process . returns ( Promise . resolve ( {
206- css : ''
207- , warnings : function ( ) {
229+ css : '' ,
230+ warnings : function ( ) {
208231 return [ ]
209232 }
210233 } ) )
@@ -216,8 +239,8 @@ describe('PostCSS Guidelines', function () {
216239 } )
217240
218241 stream . write ( new gutil . File ( {
219- contents : new Buffer ( 'a {}' )
220- , path : cssPath
242+ contents : new Buffer ( 'a {}' ) ,
243+ path : cssPath
221244 } ) )
222245
223246 stream . end ( )
@@ -228,8 +251,8 @@ describe('PostCSS Guidelines', function () {
228251
229252 var stream = postcss ( [ doubler ] , { to : 'overriden' } )
230253 postcssStub . process . returns ( Promise . resolve ( {
231- css : ''
232- , warnings : function ( ) {
254+ css : '' ,
255+ warnings : function ( ) {
233256 return [ ]
234257 }
235258 } ) )
@@ -251,19 +274,19 @@ describe('PostCSS Guidelines', function () {
251274
252275 var cssPath = __dirname + '/fixture.css'
253276 var file = new gutil . File ( {
254- contents : new Buffer ( 'a {}' )
255- , path : cssPath
277+ contents : new Buffer ( 'a {}' ) ,
278+ path : cssPath
256279 } )
257280 var plugins = [ doubler ]
258281 var callback = sandbox . stub ( ) . returns ( {
259- plugins : plugins
260- , options : { to : 'overriden' }
282+ plugins : plugins ,
283+ options : { to : 'overriden' }
261284 } )
262285 var stream = postcss ( callback )
263286
264287 postcssStub . process . returns ( Promise . resolve ( {
265- css : ''
266- , warnings : function ( ) {
288+ css : '' ,
289+ warnings : function ( ) {
267290 return [ ]
268291 }
269292 } ) )
@@ -283,28 +306,28 @@ describe('PostCSS Guidelines', function () {
283306
284307 var cssPath = __dirname + '/fixture.css'
285308 var file = new gutil . File ( {
286- contents : new Buffer ( 'a {}' )
287- , path : cssPath
309+ contents : new Buffer ( 'a {}' ) ,
310+ path : cssPath
288311 } )
289312 var stream = postcss ( { to : 'initial' } )
290313 var plugins = [ doubler ]
291314
292315 postcssLoadConfigStub . returns ( Promise . resolve ( {
293- plugins : plugins
294- , options : { to : 'overriden' }
316+ plugins : plugins ,
317+ options : { to : 'overriden' }
295318 } ) )
296319
297320 postcssStub . process . returns ( Promise . resolve ( {
298- css : ''
299- , warnings : function ( ) {
321+ css : '' ,
322+ warnings : function ( ) {
300323 return [ ]
301324 }
302325 } ) )
303326
304327 stream . on ( 'data' , function ( ) {
305328 assert . deepEqual ( postcssLoadConfigStub . getCall ( 0 ) . args [ 0 ] , {
306- file : file
307- , options : { to : 'initial' }
329+ file : file ,
330+ options : { to : 'initial' }
308331 } )
309332 assert . equal ( postcssStub . use . getCall ( 0 ) . args [ 0 ] , plugins )
310333 assert . equal ( postcssStub . process . getCall ( 0 ) . args [ 1 ] . to , 'overriden' )
@@ -320,8 +343,8 @@ describe('PostCSS Guidelines', function () {
320343 var stream = postcss ( )
321344 postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
322345 postcssStub . process . returns ( Promise . resolve ( {
323- css : ''
324- , warnings : function ( ) {
346+ css : '' ,
347+ warnings : function ( ) {
325348 return [ ]
326349 }
327350 } ) )
@@ -330,8 +353,8 @@ describe('PostCSS Guidelines', function () {
330353 cb ( )
331354 } )
332355 stream . end ( new gutil . File ( {
333- contents : new Buffer ( 'a {}' )
334- , path : cssPath
356+ contents : new Buffer ( 'a {}' ) ,
357+ path : cssPath
335358 } ) )
336359 } )
337360
@@ -340,8 +363,8 @@ describe('PostCSS Guidelines', function () {
340363 var stream = postcss ( { config : '/absolute/path' } )
341364 postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
342365 postcssStub . process . returns ( Promise . resolve ( {
343- css : ''
344- , warnings : function ( ) {
366+ css : '' ,
367+ warnings : function ( ) {
345368 return [ ]
346369 }
347370 } ) )
@@ -350,8 +373,8 @@ describe('PostCSS Guidelines', function () {
350373 cb ( )
351374 } )
352375 stream . end ( new gutil . File ( {
353- contents : new Buffer ( 'a {}' )
354- , path : cssPath
376+ contents : new Buffer ( 'a {}' ) ,
377+ path : cssPath
355378 } ) )
356379 } )
357380
@@ -360,8 +383,8 @@ describe('PostCSS Guidelines', function () {
360383 var stream = postcss ( { config : './relative/path' } )
361384 postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
362385 postcssStub . process . returns ( Promise . resolve ( {
363- css : ''
364- , warnings : function ( ) {
386+ css : '' ,
387+ warnings : function ( ) {
365388 return [ ]
366389 }
367390 } ) )
@@ -370,21 +393,21 @@ describe('PostCSS Guidelines', function () {
370393 cb ( )
371394 } )
372395 stream . end ( new gutil . File ( {
373- contents : new Buffer ( 'a {}' )
374- , path : cssPath
375- , base : __dirname
396+ contents : new Buffer ( 'a {}' ) ,
397+ path : cssPath ,
398+ base : __dirname
376399 } ) )
377400 } )
378401
379402 it ( 'should not override `from` and `map` if using gulp-sourcemaps' , function ( cb ) {
380403 var stream = postcss ( [ doubler ] , { from : 'overriden' , map : 'overriden' } )
381404 var cssPath = __dirname + '/fixture.css'
382405 postcssStub . process . returns ( Promise . resolve ( {
383- css : ''
384- , warnings : function ( ) {
406+ css : '' ,
407+ warnings : function ( ) {
385408 return [ ]
386- }
387- , map : {
409+ } ,
410+ map : {
388411 toJSON : function ( ) {
389412 return {
390413 sources : [ ] ,
@@ -407,8 +430,8 @@ describe('PostCSS Guidelines', function () {
407430 } )
408431
409432 var file = new gutil . File ( {
410- contents : new Buffer ( 'a {}' )
411- , path : cssPath
433+ contents : new Buffer ( 'a {}' ) ,
434+ path : cssPath
412435 } )
413436 file . sourceMap = { }
414437 stream . end ( file )
@@ -448,8 +471,8 @@ describe('PostCSS Guidelines', function () {
448471
449472 sandbox . stub ( gutil , 'log' )
450473 postcssStub . process . returns ( Promise . resolve ( {
451- css : ''
452- , warnings : function ( ) {
474+ css : '' ,
475+ warnings : function ( ) {
453476 return [ new Warning ( 'msg1' ) , new Warning ( 'msg2' ) ]
454477 }
455478 } ) )
@@ -460,8 +483,8 @@ describe('PostCSS Guidelines', function () {
460483 } )
461484
462485 stream . write ( new gutil . File ( {
463- contents : new Buffer ( 'a {}' )
464- , path : cssPath
486+ contents : new Buffer ( 'a {}' ) ,
487+ path : cssPath
465488 } ) )
466489
467490 stream . end ( )
@@ -478,8 +501,8 @@ describe('PostCSS Guidelines', function () {
478501 var stream = postcss ( [ doubler ] , options )
479502 var cssPath = __dirname + '/src/fixture.css'
480503 postcssStub . process . returns ( Promise . resolve ( {
481- css : ''
482- , warnings : function ( ) {
504+ css : '' ,
505+ warnings : function ( ) {
483506 return [ ]
484507 }
485508 } ) )
@@ -495,8 +518,8 @@ describe('PostCSS Guidelines', function () {
495518 } )
496519
497520 stream . write ( new gutil . File ( {
498- contents : new Buffer ( 'a {}' )
499- , path : cssPath
521+ contents : new Buffer ( 'a {}' ) ,
522+ path : cssPath
500523 } ) )
501524
502525 stream . end ( )
0 commit comments