11import test from 'ava' ;
22import postcss from 'postcss' ;
33import _ from 'lodash' ;
4- import Promise from 'bluebird' ;
54import fs from 'fs-extra' ;
65import path from 'path' ;
76import {
@@ -13,14 +12,12 @@ import {
1312 saveSpritesheets
1413} from '../lib/core' ;
1514
16- const readFileAsync = Promise . promisify ( fs . readFile ) ;
17-
1815test . beforeEach ( ( t ) => {
1916 t . context . opts = _ . merge ( { logger ( ) { } } , defaults ) ;
2017} ) ;
2118
2219test ( 'should save spritesheets' , async ( t ) => {
23- const cssContents = await readFileAsync ( './test/fixtures/basic/style.css' ) ;
20+ const cssContents = await fs . readFile ( './test/fixtures/basic/style.css' ) ;
2421 const ast = postcss . parse ( cssContents , { from : './test/fixtures/basic/style.css' } ) ;
2522 let images , spritesheets , opts ;
2623
@@ -31,11 +28,11 @@ test('should save spritesheets', async (t) => {
3128 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
3229
3330 t . deepEqual ( spritesheets [ 0 ] . path , 'test/build/basic/sprite.png' ) ;
34- t . truthy ( fs . statAsync ( './test/build/basic/sprite.png' ) ) ;
31+ t . truthy ( fs . stat ( './test/build/basic/sprite.png' ) ) ;
3532} ) ;
3633
3734test ( 'should save SVG spritesheets' , async ( t ) => {
38- const cssContents = await readFileAsync ( './test/fixtures/svg-basic/style.css' ) ;
35+ const cssContents = await fs . readFile ( './test/fixtures/svg-basic/style.css' ) ;
3936 const ast = postcss . parse ( cssContents , { from : './test/fixtures/svg-basic/style.css' } ) ;
4037 let images , spritesheets , opts ;
4138
@@ -48,11 +45,11 @@ test('should save SVG spritesheets', async (t) => {
4845 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
4946
5047 t . deepEqual ( spritesheets [ 0 ] . path , 'test/build/svg-basic/sprite.svg' ) ;
51- t . truthy ( fs . statAsync ( './test/build/svg-basic/sprite.svg' ) ) ;
48+ t . truthy ( fs . stat ( './test/build/svg-basic/sprite.svg' ) ) ;
5249} ) ;
5350
5451test ( 'should save spritesheets by groups' , async ( t ) => {
55- const cssContents = await readFileAsync ( './test/fixtures/retina/style.css' ) ;
52+ const cssContents = await fs . readFile ( './test/fixtures/retina/style.css' ) ;
5653 const ast = postcss . parse ( cssContents , { from : './test/fixtures/retina/style.css' } ) ;
5754 let images , spritesheets , opts ;
5855
@@ -68,12 +65,12 @@ test('should save spritesheets by groups', async (t) => {
6865
6966 t . deepEqual ( spritesheets [ 0 ] . path , 'test/build/retina/sprite.png' ) ;
7067 t . deepEqual ( spritesheets [ 1 ] . path , 'test/build/retina/sprite.@2x.png' ) ;
71- t . truthy ( fs . statAsync ( './test/build/retina/sprite.png' ) ) ;
72- t . truthy ( fs . statAsync ( './test/build/retina/sprite.@2x.png' ) ) ;
68+ t . truthy ( fs . stat ( './test/build/retina/sprite.png' ) ) ;
69+ t . truthy ( fs . stat ( './test/build/retina/sprite.@2x.png' ) ) ;
7370} ) ;
7471
7572test ( 'should use path provided by book' , async ( t ) => {
76- const cssContents = await readFileAsync ( './test/fixtures/basic/style.css' ) ;
73+ const cssContents = await fs . readFile ( './test/fixtures/basic/style.css' ) ;
7774 const ast = postcss . parse ( cssContents , { from : './test/fixtures/basic/style.css' } ) ;
7875 let images , spritesheets , opts ;
7976
@@ -87,11 +84,11 @@ test('should use path provided by book', async (t) => {
8784 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
8885
8986 t . deepEqual ( spritesheets [ 0 ] . path , 'test/build/on-save-hook/custom-name.png' ) ;
90- t . truthy ( fs . statAsync ( './test/build/on-save-hook/custom-name.png' ) ) ;
87+ t . truthy ( fs . stat ( './test/build/on-save-hook/custom-name.png' ) ) ;
9188} ) ;
9289
9390test ( 'should throw error if path is empty' , async ( t ) => {
94- const cssContents = await readFileAsync ( './test/fixtures/basic/style.css' ) ;
91+ const cssContents = await fs . readFile ( './test/fixtures/basic/style.css' ) ;
9592 const ast = postcss . parse ( cssContents , { from : './test/fixtures/basic/style.css' } ) ;
9693 let images , spritesheets , opts ;
9794
@@ -107,7 +104,7 @@ test('should throw error if path is empty', async (t) => {
107104} ) ;
108105
109106test ( 'should use Promise result provided by book' , async ( t ) => {
110- const cssContents = await readFileAsync ( './test/fixtures/basic/style.css' ) ;
107+ const cssContents = await fs . readFile ( './test/fixtures/basic/style.css' ) ;
111108 const ast = postcss . parse ( cssContents , { from : './test/fixtures/basic/style.css' } ) ;
112109 let images , spritesheets , opts ;
113110
@@ -121,5 +118,5 @@ test('should use Promise result provided by book', async (t) => {
121118 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
122119
123120 t . deepEqual ( spritesheets [ 0 ] . path , 'test/build/on-save-hook/custom-name.png' ) ;
124- t . truthy ( fs . statAsync ( './test/build/on-save-hook/custom-name.png' ) ) ;
121+ t . truthy ( fs . stat ( './test/build/on-save-hook/custom-name.png' ) ) ;
125122} ) ;
0 commit comments