@@ -2,12 +2,11 @@ var chai = require('chai');
22var sinon = require ( 'sinon' ) ;
33var child = require ( 'child_process' ) ;
44var exec = child . exec ;
5- var fs = require ( 'fs' ) ;
65var rewire = require ( 'rewire' ) ;
76var suitcss = rewire ( '../lib' ) ;
8- var path = require ( 'path' ) ;
97var sinonChai = require ( 'sinon-chai' ) ;
108var chaiAsPromised = require ( 'chai-as-promised' ) ;
9+ var util = require ( './util' ) ;
1110require ( 'sinon-as-promised' ) ;
1211
1312chai . use ( sinonChai ) ;
@@ -261,7 +260,7 @@ describe('suitcss', function() {
261260 describe ( 'stylelint' , function ( ) {
262261 it ( 'should lint the component' , function ( ) {
263262 return expect (
264- suitcss ( read ( 'fixtures/component' ) , {
263+ suitcss ( util . read ( 'fixtures/component' ) , {
265264 root : 'test/fixtures' ,
266265 'postcss-reporter' : {
267266 throwError : true
@@ -300,7 +299,8 @@ describe('suitcss', function() {
300299
301300 it ( 'should lint the input file' , function ( ) {
302301 return expect (
303- suitcss ( 'body {}' , {
302+ suitcss ( '@import "./stylelint.css"\n\n' , {
303+ root : 'test/fixtures' ,
304304 'postcss-reporter' : {
305305 throwError : true
306306 }
@@ -317,8 +317,8 @@ describe('suitcss', function() {
317317
318318describe ( 'features' , function ( ) {
319319 it ( 'should preprocess CSS correctly' , function ( done ) {
320- var input = read ( 'fixtures/component' ) ;
321- var output = read ( 'fixtures/component.out' ) ;
320+ var input = util . read ( 'fixtures/component' ) ;
321+ var output = util . read ( 'fixtures/component.out' ) ;
322322
323323 suitcss ( input , {
324324 root : 'test/fixtures' ,
@@ -352,17 +352,17 @@ describe('features', function() {
352352 */
353353
354354describe ( 'cli' , function ( ) {
355- var input = read ( 'fixtures/cli/input' ) ;
356- var output = read ( 'fixtures/cli/input.out' ) ;
355+ var input = util . read ( 'fixtures/cli/input' ) ;
356+ var output = util . read ( 'fixtures/cli/input.out' ) ;
357357
358358 afterEach ( function ( ) {
359- remove ( 'fixtures/cli/output' ) ;
359+ util . remove ( 'fixtures/cli/output' ) ;
360360 } ) ;
361361
362362 it ( 'should read from a file and write to a file' , function ( done ) {
363363 exec ( 'node bin/suitcss -c test/config/noautoprefixer.config.js test/fixtures/cli/input.css test/fixtures/cli/output.css' , function ( err ) {
364364 if ( err ) return done ( err ) ;
365- var res = read ( 'fixtures/cli/output' ) ;
365+ var res = util . read ( 'fixtures/cli/output' ) ;
366366 expect ( res ) . to . equal ( output ) ;
367367 done ( ) ;
368368 } ) ;
@@ -398,8 +398,8 @@ describe('cli', function() {
398398 it ( 'should allow configurable import root' , function ( done ) {
399399 exec ( 'node bin/suitcss -i test/fixtures -c test/config/noautoprefixer.config.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
400400 if ( err ) return done ( err ) ;
401- var res = read ( 'fixtures/cli/output' ) ;
402- var expected = read ( 'fixtures/component.out' ) ;
401+ var res = util . read ( 'fixtures/cli/output' ) ;
402+ var expected = util . read ( 'fixtures/component.out' ) ;
403403 expect ( res ) . to . equal ( expected ) ;
404404 done ( ) ;
405405 } ) ;
@@ -416,8 +416,8 @@ describe('cli', function() {
416416 it ( 'should minify the output' , function ( done ) {
417417 exec ( 'node bin/suitcss -i test/fixtures -c test/config/noautoprefixer.config.js test/fixtures/import.css test/fixtures/cli/output.css -m' , function ( err ) {
418418 if ( err ) return done ( err ) ;
419- var res = read ( 'fixtures/cli/output' ) ;
420- var expected = read ( 'fixtures/minify.out' ) ;
419+ var res = util . read ( 'fixtures/cli/output' ) ;
420+ var expected = util . read ( 'fixtures/minify.out' ) ;
421421 expect ( res ) . to . equal ( expected ) ;
422422 done ( ) ;
423423 } ) ;
@@ -426,8 +426,8 @@ describe('cli', function() {
426426 it ( 'should allow a config file to be passed' , function ( done ) {
427427 exec ( 'node bin/suitcss -i test/fixtures -c test/config/test.config.js test/fixtures/config.css test/fixtures/cli/output.css' , function ( err ) {
428428 if ( err ) return done ( err ) ;
429- var res = read ( 'fixtures/cli/output' ) ;
430- var expected = read ( 'fixtures/config.out' ) ;
429+ var res = util . read ( 'fixtures/cli/output' ) ;
430+ var expected = util . read ( 'fixtures/config.out' ) ;
431431 expect ( res ) . to . equal ( expected ) ;
432432 done ( ) ;
433433 } ) ;
@@ -451,38 +451,3 @@ describe('cli', function() {
451451 } ) ;
452452 } ) ;
453453} ) ;
454-
455- /**
456- * Read a fixture by `filename`.
457- *
458- * @param {String } filename
459- * @return {String }
460- */
461-
462- function read ( filename ) {
463- var file = resolve ( filename ) ;
464- return fs . readFileSync ( file , 'utf8' ) ;
465- }
466-
467- /**
468- * Remove a fixture by `filename`.
469- *
470- * @param {String } filename
471- */
472-
473- function remove ( filename ) {
474- var file = resolve ( filename ) ;
475- if ( ! fs . existsSync ( file ) ) return ;
476- fs . unlinkSync ( file ) ;
477- }
478-
479- /**
480- * Resolve a fixture by `filename`.
481- *
482- * @param {String } filename
483- * @return {String }
484- */
485-
486- function resolve ( filename ) {
487- return path . resolve ( __dirname , filename + '.css' ) ;
488- }
0 commit comments