@@ -20,43 +20,43 @@ test.beforeEach((t) => {
2020} ) ;
2121
2222test ( 'should save spritesheets' , async ( t ) => {
23- const cssContents = await readFileAsync ( './fixtures/basic/style.css' ) ;
24- const ast = postcss . parse ( cssContents , { from : './fixtures/basic/style.css' } ) ;
23+ const cssContents = await readFileAsync ( './test/ fixtures/basic/style.css' ) ;
24+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/basic/style.css' } ) ;
2525 let images , spritesheets , opts ;
2626
27- t . context . opts . spritePath = './build/basic' ;
27+ t . context . opts . spritePath = './test/ build/basic' ;
2828
2929 [ opts , images ] = await extractImages ( ast , t . context . opts ) ;
3030 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
3131 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
3232
33- t . deepEqual ( spritesheets [ 0 ] . path , 'build/basic/sprite.png' ) ;
34- t . truthy ( fs . statAsync ( './build/basic/sprite.png' ) ) ;
33+ t . deepEqual ( spritesheets [ 0 ] . path , 'test/ build/basic/sprite.png' ) ;
34+ t . truthy ( fs . statAsync ( './test/ build/basic/sprite.png' ) ) ;
3535} ) ;
3636
3737test ( 'should save SVG spritesheets' , async ( t ) => {
38- const cssContents = await readFileAsync ( './fixtures/svg-basic/style.css' ) ;
39- const ast = postcss . parse ( cssContents , { from : './fixtures/svg-basic/style.css' } ) ;
38+ const cssContents = await readFileAsync ( './test/ fixtures/svg-basic/style.css' ) ;
39+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/svg-basic/style.css' } ) ;
4040 let images , spritesheets , opts ;
4141
42- t . context . opts . spritePath = './build/svg-basic' ;
42+ t . context . opts . spritePath = './test/ build/svg-basic' ;
4343
4444 prepareGroupBy ( t . context . opts ) ;
4545 [ opts , images ] = await extractImages ( ast , t . context . opts ) ;
4646 [ opts , images ] = await applyGroupBy ( t . context . opts , images ) ;
4747 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
4848 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
4949
50- t . deepEqual ( spritesheets [ 0 ] . path , 'build/svg-basic/sprite.svg' ) ;
51- t . truthy ( fs . statAsync ( './build/svg-basic/sprite.svg' ) ) ;
50+ t . deepEqual ( spritesheets [ 0 ] . path , 'test/ build/svg-basic/sprite.svg' ) ;
51+ t . truthy ( fs . statAsync ( './test/ build/svg-basic/sprite.svg' ) ) ;
5252} ) ;
5353
5454test ( 'should save spritesheets by groups' , async ( t ) => {
55- const cssContents = await readFileAsync ( './fixtures/retina/style.css' ) ;
56- const ast = postcss . parse ( cssContents , { from : './fixtures/retina/style.css' } ) ;
55+ const cssContents = await readFileAsync ( './test/ fixtures/retina/style.css' ) ;
56+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/retina/style.css' } ) ;
5757 let images , spritesheets , opts ;
5858
59- t . context . opts . spritePath = './build/retina' ;
59+ t . context . opts . spritePath = './test/ build/retina' ;
6060 t . context . opts . retina = true ;
6161
6262 prepareGroupBy ( t . context . opts ) ;
@@ -66,18 +66,18 @@ test('should save spritesheets by groups', async (t) => {
6666 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
6767 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
6868
69- t . deepEqual ( spritesheets [ 0 ] . path , 'build/retina/sprite.png' ) ;
70- t . deepEqual ( spritesheets [ 1 ] . path , 'build/retina/sprite.@2x.png' ) ;
71- t . truthy ( fs . statAsync ( './build/retina/sprite.png' ) ) ;
72- t . truthy ( fs . statAsync ( './build/retina/sprite.@2x.png' ) ) ;
69+ t . deepEqual ( spritesheets [ 0 ] . path , 'test/ build/retina/sprite.png' ) ;
70+ 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' ) ) ;
7373} ) ;
7474
7575test ( 'should use path provided by book' , async ( t ) => {
76- const cssContents = await readFileAsync ( './fixtures/basic/style.css' ) ;
77- const ast = postcss . parse ( cssContents , { from : './fixtures/basic/style.css' } ) ;
76+ const cssContents = await readFileAsync ( './test/ fixtures/basic/style.css' ) ;
77+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/basic/style.css' } ) ;
7878 let images , spritesheets , opts ;
7979
80- t . context . opts . spritePath = './build/on-save-hook/' ;
80+ t . context . opts . spritePath = './test/ build/on-save-hook/' ;
8181 t . context . opts . hooks . onSaveSpritesheet = ( pluginOpts , spritesheetGroups ) => {
8282 return path . join ( pluginOpts . spritePath , 'custom-name.png' ) ;
8383 }
@@ -86,32 +86,32 @@ test('should use path provided by book', async (t) => {
8686 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
8787 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
8888
89- t . deepEqual ( spritesheets [ 0 ] . path , 'build/on-save-hook/custom-name.png' ) ;
90- t . truthy ( fs . statAsync ( './build/on-save-hook/custom-name.png' ) ) ;
89+ 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' ) ) ;
9191} ) ;
9292
9393test ( 'should throw error if path is empty' , async ( t ) => {
94- const cssContents = await readFileAsync ( './fixtures/basic/style.css' ) ;
95- const ast = postcss . parse ( cssContents , { from : './fixtures/basic/style.css' } ) ;
94+ const cssContents = await readFileAsync ( './test/ fixtures/basic/style.css' ) ;
95+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/basic/style.css' } ) ;
9696 let images , spritesheets , opts ;
9797
98- t . context . opts . spritePath = './build/on-save-hook/' ;
98+ t . context . opts . spritePath = './test/ build/on-save-hook/' ;
9999 t . context . opts . hooks . onSaveSpritesheet = ( pluginOpts , spritesheetGroups ) => {
100100 return '' ;
101101 }
102102
103103 [ opts , images ] = await extractImages ( ast , t . context . opts ) ;
104104 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
105105
106- t . throws ( saveSpritesheets ( t . context . opts , images , spritesheets ) ) ;
106+ return t . throwsAsync ( ( ) => saveSpritesheets ( t . context . opts , images , spritesheets ) ) ;
107107} ) ;
108108
109109test ( 'should use Promise result provided by book' , async ( t ) => {
110- const cssContents = await readFileAsync ( './fixtures/basic/style.css' ) ;
111- const ast = postcss . parse ( cssContents , { from : './fixtures/basic/style.css' } ) ;
110+ const cssContents = await readFileAsync ( './test/ fixtures/basic/style.css' ) ;
111+ const ast = postcss . parse ( cssContents , { from : './test/ fixtures/basic/style.css' } ) ;
112112 let images , spritesheets , opts ;
113113
114- t . context . opts . spritePath = './build/on-save-hook/' ;
114+ t . context . opts . spritePath = './test/ build/on-save-hook/' ;
115115 t . context . opts . hooks . onSaveSpritesheet = ( pluginOpts , spritesheetGroups ) => {
116116 return new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( Promise . resolve ( path . join ( pluginOpts . spritePath , 'custom-name.png' ) ) ) , 0 ) ) ;
117117 }
@@ -120,6 +120,6 @@ test('should use Promise result provided by book', async (t) => {
120120 [ opts , images , spritesheets ] = await runSpritesmith ( t . context . opts , images ) ;
121121 [ opts , images , spritesheets ] = await saveSpritesheets ( t . context . opts , images , spritesheets ) ;
122122
123- t . deepEqual ( spritesheets [ 0 ] . path , 'build/on-save-hook/custom-name.png' ) ;
124- t . truthy ( fs . statAsync ( './build/on-save-hook/custom-name.png' ) ) ;
123+ 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' ) ) ;
125125} ) ;
0 commit comments