1- var expect = require ( 'chai' ) . expect ;
1+ var chai = require ( 'chai' ) ;
22var sinon = require ( 'sinon' ) ;
33var child = require ( 'child_process' ) ;
44var exec = child . exec ;
55var fs = require ( 'fs' ) ;
66var rewire = require ( 'rewire' ) ;
77var suitcss = rewire ( '../lib' ) ;
88var path = require ( 'path' ) ;
9+ var sinonChai = require ( 'sinon-chai' ) ;
10+
11+ chai . use ( sinonChai ) ;
12+ var expect = chai . expect ;
913
1014/**
1115 * Node API tests.
@@ -56,7 +60,7 @@ describe('suitcss', function() {
5660 expect ( opts . lint ) . to . be . true ;
5761 } ) ;
5862
59- it ( 'should allow an minify option to be set' , function ( ) {
63+ it ( 'should allow a minify option to be set' , function ( ) {
6064 var opts = mergeOptions ( { minify : true } ) ;
6165 expect ( opts . minify ) . to . be . true ;
6266 } ) ;
@@ -148,7 +152,7 @@ describe('suitcss', function() {
148152
149153 describe ( 'stylelint' , function ( ) {
150154 it ( 'should check the input conforms to SUIT style rules' , function ( done ) {
151- suitcss ( '@import ./stylelint.css' , {
155+ suitcss ( '@import " ./stylelint.css" ' , {
152156 lint : true ,
153157 root : 'test/fixtures' ,
154158 'postcss-reporter' : {
@@ -163,53 +167,50 @@ describe('suitcss', function() {
163167 } ) ;
164168 } ) ;
165169
166- describe ( 'beforeLint option ' , function ( ) {
167- var lintImportedFilesStub , bemLintStub , beforeLintStub , revert ;
170+ describe ( 'transforming css before linting ' , function ( ) {
171+ var lintImportedFilesStub , beforeLintStub , revert ;
168172
169173 beforeEach ( function ( ) {
170- lintImportedFilesStub = sinon . stub ( ) ;
171- bemLintStub = sinon . stub ( ) . returns ( '/* lint */' ) ;
172- beforeLintStub = sinon . stub ( ) . returns ( '/* before lint */' ) ;
173-
174- lintImportedFilesStub . onFirstCall ( ) . returns ( bemLintStub ) ;
174+ lintImportedFilesStub = sinon . stub ( ) . returns ( '/*linting done*/' ) ;
175+ beforeLintStub = sinon . stub ( ) . returns ( '/*before lint*/' ) ;
175176 revert = suitcss . __set__ ( 'lintImportedFiles' , lintImportedFilesStub ) ;
176177 } ) ;
177178
178179 afterEach ( function ( ) {
179180 revert ( ) ;
180181 } ) ;
181182
182- it ( 'should call user supplied function before linting' , function ( done ) {
183+ it ( 'should call `beforeLint` function before linting' , function ( done ) {
183184 suitcss ( read ( 'fixtures/component' ) , {
184185 root : 'test/fixtures' ,
185186 beforeLint : beforeLintStub
186187 } ) . catch ( done ) ;
187188
188- expect ( bemLintStub . calledOnce ) . to . be . ok ;
189- expect ( beforeLintStub . calledOnce ) . to . be . ok ;
190- expect ( beforeLintStub . calledBefore ( bemLintStub ) ) . to . be . ok ;
189+ expect ( lintImportedFilesStub ) . to . be . calledOnce ;
190+ expect ( beforeLintStub ) . to . be . calledOnce ;
191+ expect ( beforeLintStub ) . to . have . been . calledBefore ( lintImportedFilesStub ) ;
191192
192193 done ( ) ;
193194 } ) ;
194195
195- it ( 'should pass processed CSS to the linting transform function ' , function ( done ) {
196+ it ( 'should pass the result of `beforeLint` to `lintImportedFiles` ' , function ( done ) {
196197 suitcss ( read ( 'fixtures/component' ) , {
197198 root : 'test/fixtures' ,
198199 beforeLint : beforeLintStub
199200 } ) . catch ( done ) ;
200201
201- expect ( bemLintStub . args [ 0 ] [ 0 ] ) . to . equal ( '/* before lint */' ) ;
202+ expect ( lintImportedFilesStub . args [ 0 ] [ 1 ] ) . to . equal ( '/*before lint*/' ) ;
202203
203204 done ( ) ;
204205 } ) ;
205206
206- it ( 'should pass the merged options to the beforeLint function' , function ( done ) {
207+ it ( 'should pass the options object to the beforeLint function as the third parameter ' , function ( done ) {
207208 suitcss ( read ( 'fixtures/component' ) , {
208209 root : 'test/fixtures' ,
209210 beforeLint : beforeLintStub
210211 } ) . catch ( done ) ;
211212
212- expect ( beforeLintStub . args [ 0 ] [ 2 ] . root ) . to . equal ( 'test/fixtures' ) ;
213+ expect ( beforeLintStub . args [ 0 ] [ 2 ] ) . to . contain ( { root : 'test/fixtures' } ) ;
213214
214215 done ( ) ;
215216 } ) ;
0 commit comments