1
- /* global it, afterEach, describe, Promise */
1
+ /* global it, afterEach, beforeEach, describe, Promise */
2
2
3
3
require ( 'es6-promise' ) . polyfill ( )
4
4
var assert = require ( 'assert' )
@@ -123,8 +123,8 @@ describe('PostCSS Guidelines', function () {
123
123
}
124
124
}
125
125
var postcssStub = {
126
- use : sandbox . stub ( )
127
- , process : sandbox . stub ( )
126
+ use : function ( ) { }
127
+ , process : function ( ) { }
128
128
}
129
129
var postcss = proxyquire ( './index' , {
130
130
postcss : function ( ) {
@@ -133,6 +133,10 @@ describe('PostCSS Guidelines', function () {
133
133
, 'postcss/lib/css-syntax-error' : CssSyntaxError
134
134
} )
135
135
136
+ beforeEach ( function ( ) {
137
+ sandbox . stub ( postcssStub , 'use' )
138
+ sandbox . stub ( postcssStub , 'process' )
139
+ } )
136
140
137
141
afterEach ( function ( ) {
138
142
sandbox . restore ( )
@@ -151,7 +155,8 @@ describe('PostCSS Guidelines', function () {
151
155
} ) )
152
156
153
157
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 )
155
160
cb ( )
156
161
} )
157
162
@@ -164,6 +169,28 @@ describe('PostCSS Guidelines', function () {
164
169
165
170
} )
166
171
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
+ } )
167
194
168
195
it ( 'should not output js stack trace for `CssSyntaxError`' , function ( cb ) {
169
196
0 commit comments