@@ -168,8 +168,8 @@ describe('PostCSS Guidelines', function () {
168168 postcssStub . use ( plugins )
169169 return postcssStub
170170 }
171- , 'postcss-load-config' : function ( ctx ) {
172- return postcssLoadConfigStub ( ctx )
171+ , 'postcss-load-config' : function ( ctx , configPath ) {
172+ return postcssLoadConfigStub ( ctx , configPath )
173173 }
174174 , 'vinyl-sourcemaps-apply' : function ( ) {
175175 return { }
@@ -303,6 +303,67 @@ describe('PostCSS Guidelines', function () {
303303
304304 } )
305305
306+ it ( 'should point the config location to file directory' , function ( cb ) {
307+ var cssPath = __dirname + '/fixture.css'
308+ var stream = postcss ( )
309+ postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
310+ postcssStub . process . returns ( Promise . resolve ( {
311+ css : ''
312+ , warnings : function ( ) {
313+ return [ ]
314+ }
315+ } ) )
316+ stream . on ( 'data' , function ( ) {
317+ assert . deepEqual ( postcssLoadConfigStub . getCall ( 0 ) . args [ 1 ] , __dirname )
318+ cb ( )
319+ } )
320+ stream . end ( new gutil . File ( {
321+ contents : new Buffer ( 'a {}' )
322+ , path : cssPath
323+ } ) )
324+ } )
325+
326+ it ( 'should set the config location from option' , function ( cb ) {
327+ var cssPath = __dirname + '/fixture.css'
328+ var stream = postcss ( { config : '/absolute/path' } )
329+ postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
330+ postcssStub . process . returns ( Promise . resolve ( {
331+ css : ''
332+ , warnings : function ( ) {
333+ return [ ]
334+ }
335+ } ) )
336+ stream . on ( 'data' , function ( ) {
337+ assert . deepEqual ( postcssLoadConfigStub . getCall ( 0 ) . args [ 1 ] , '/absolute/path' )
338+ cb ( )
339+ } )
340+ stream . end ( new gutil . File ( {
341+ contents : new Buffer ( 'a {}' )
342+ , path : cssPath
343+ } ) )
344+ } )
345+
346+ it ( 'should set the config location from option relative to the base dir' , function ( cb ) {
347+ var cssPath = __dirname + '/src/fixture.css'
348+ var stream = postcss ( { config : './relative/path' } )
349+ postcssLoadConfigStub . returns ( Promise . resolve ( { plugins : [ ] } ) )
350+ postcssStub . process . returns ( Promise . resolve ( {
351+ css : ''
352+ , warnings : function ( ) {
353+ return [ ]
354+ }
355+ } ) )
356+ stream . on ( 'data' , function ( ) {
357+ assert . deepEqual ( postcssLoadConfigStub . getCall ( 0 ) . args [ 1 ] , __dirname + '/relative/path' )
358+ cb ( )
359+ } )
360+ stream . end ( new gutil . File ( {
361+ contents : new Buffer ( 'a {}' )
362+ , path : cssPath
363+ , base : __dirname
364+ } ) )
365+ } )
366+
306367 it ( 'should not override `from` and `map` if using gulp-sourcemaps' , function ( cb ) {
307368 var stream = postcss ( [ doubler ] , { from : 'overriden' , map : 'overriden' } )
308369 var cssPath = __dirname + '/fixture.css'
0 commit comments