1- /* global it, afterEach, describe, Promise */
1+ /* global it, afterEach, beforeEach, describe, Promise */
22
33require ( 'es6-promise' ) . polyfill ( )
44var assert = require ( 'assert' )
@@ -123,8 +123,8 @@ describe('PostCSS Guidelines', function () {
123123 }
124124 }
125125 var postcssStub = {
126- use : sandbox . stub ( )
127- , process : sandbox . stub ( )
126+ use : function ( ) { }
127+ , process : function ( ) { }
128128 }
129129 var postcss = proxyquire ( './index' , {
130130 postcss : function ( ) {
@@ -133,6 +133,10 @@ describe('PostCSS Guidelines', function () {
133133 , 'postcss/lib/css-syntax-error' : CssSyntaxError
134134 } )
135135
136+ beforeEach ( function ( ) {
137+ sandbox . stub ( postcssStub , 'use' )
138+ sandbox . stub ( postcssStub , 'process' )
139+ } )
136140
137141 afterEach ( function ( ) {
138142 sandbox . restore ( )
@@ -151,7 +155,8 @@ describe('PostCSS Guidelines', function () {
151155 } ) )
152156
153157 stream . on ( 'data' , function ( ) {
154- postcssStub . process . calledWith ( 'a {}' , { from : cssPath , to : cssPath } )
158+ assert . equal ( postcssStub . process . getCall ( 0 ) . args [ 1 ] . to , cssPath )
159+ assert . equal ( postcssStub . process . getCall ( 0 ) . args [ 1 ] . from , cssPath )
155160 cb ( )
156161 } )
157162
@@ -164,6 +169,28 @@ describe('PostCSS Guidelines', function () {
164169
165170 } )
166171
172+ it ( 'should allow override of `to` processing option' , function ( cb ) {
173+
174+ var stream = postcss ( [ doubler ] , { to : 'overriden' } )
175+ postcssStub . process . returns ( Promise . resolve ( {
176+ css : ''
177+ , warnings : function ( ) {
178+ return [ ]
179+ }
180+ } ) )
181+
182+ stream . on ( 'data' , function ( ) {
183+ assert . equal ( postcssStub . process . getCall ( 0 ) . args [ 1 ] . to , 'overriden' )
184+ cb ( )
185+ } )
186+
187+ stream . write ( new gutil . File ( {
188+ contents : new Buffer ( 'a {}' )
189+ } ) )
190+
191+ stream . end ( )
192+
193+ } )
167194
168195 it ( 'should not output js stack trace for `CssSyntaxError`' , function ( cb ) {
169196
0 commit comments