Skip to content

Commit a142e3e

Browse files
committed
Tests use top-down sprite packing for consistency
1 parent 7523db8 commit a142e3e

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

test/test-css/expected/background.min.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
width: 120px;
33
height: 100px;
44
background: url(spritesheet.png);
5-
background-position: -0px -0px;
5+
background-position: -0px -64px;
66
}
77

88
.massa {
99
width: 120px;
1010
height: 100px;
1111
background: url(spritesheet.png) #ff0;
12-
background-position: -120px -0px;
12+
background-position: -0px -0px;
1313
}
1414

1515
.loremdummy {

test/test-css/expected/overall-include-implicit.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
width: 120px;
33
height: 100px;
44
background: url('spritesheet.png');
5-
background-position: -300px -0px;
5+
background-position: -0px -308px;
66
}
77

88
.aenean-double-quotes {
99
width: 120px;
1010
height: 100px;
1111
background: url("spritesheet.png");
12-
background-position: -300px -0px;
12+
background-position: -0px -308px;
1313
}
1414

1515
.jpg {
1616
width: 100px;
1717
height: 160px;
1818
background: url('spritesheet.png');
19-
background-position: -200px -0px;
19+
background-position: -0px -408px;
2020
}
2121

2222
.gif {
2323
width: 100px;
2424
height: 160px;
2525
background: url('spritesheet.png');
26-
background-position: -260px -270px;
26+
background-position: -0px -0px;
2727
}
2828

2929
.massa {
3030
width: 120px;
3131
height: 100px;
3232
background: #ffff00 url('spritesheet.png');
33-
background-position: -300px -100px;
33+
background-position: -0px -100px;
3434
}
3535

3636
.not-going-to-be-found {
@@ -50,7 +50,7 @@
5050
width: 64px;
5151
height: 64px;
5252
background-image: url('spritesheet.png');
53-
background-position: -300px -164px;
53+
background-position: -0px -164px;
5454
}
5555

5656
.qwerqwer {
@@ -62,7 +62,7 @@
6262
width: 300px;
6363
height: 80px;
6464
background: url('spritesheet.png'), url('spritesheet.png');
65-
background-position: -364px -100px, -0px -270px;
65+
background-position: -0px -50px, -0px -228px;
6666
}
6767

6868
.meta-include-false {
@@ -77,7 +77,7 @@
7777
height: 64px;
7878
/* @meta {"spritesheet": {"include": true}} */
7979
background-image: url('spritesheet.png');
80-
background-position: -0px -0px;
80+
background-position: -0px -568px;
8181
}
8282

8383
.external-image {

test/test.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var transformMap = require('../lib/transform-map');
2727

2828

2929

30-
30+
// We use 'algorithm': 'top-down' because it easier to have a consistent packing so the expected doesn't have to be updated
3131
describe('gulp-css-spriter', function() {
3232
it('should emit a buffer', function() {
3333
var spriterPromise = spriterTest({}).then(function(result) {
@@ -38,28 +38,46 @@ describe('gulp-css-spriter', function() {
3838
});
3939

4040
it('should work with minified css', function() {
41-
return compareSpriterResultsToExpected('test/test-css/background.min.css', 'test/test-css/expected/background.min.css');
41+
return compareSpriterResultsToExpected('test/test-css/background.min.css', 'test/test-css/expected/background.min.css', {
42+
'spritesmithOptions': {
43+
'algorithm': 'top-down'
44+
}
45+
});
4246
});
4347

4448
it('should not try to sprite external images', function() {
45-
return compareSpriterResultsToExpected('test/test-css/external-image.css', 'test/test-css/expected/external-image.css');
49+
return compareSpriterResultsToExpected('test/test-css/external-image.css', 'test/test-css/expected/external-image.css', {
50+
'spritesmithOptions': {
51+
'algorithm': 'top-down'
52+
}
53+
});
4654
});
4755

4856
it('should sprite properly when the same image source is used in multiple declarations. And one of the declarations is excluded via meta data', function() {
49-
return compareSpriterResultsToExpected('test/test-css/multiple-declarations-same-image.css', 'test/test-css/expected/multiple-declarations-same-image.css');
57+
return compareSpriterResultsToExpected('test/test-css/multiple-declarations-same-image.css', 'test/test-css/expected/multiple-declarations-same-image.css', {
58+
'spritesmithOptions': {
59+
'algorithm': 'top-down'
60+
}
61+
});
5062
});
5163

5264
// All declarations will be included except those with explcit `includeMode` false meta data
5365
it('should work in implicit mode `options.includeMode`', function() {
5466
return compareSpriterResultsToExpected('test/test-css/overall.css', 'test/test-css/expected/overall-include-implicit.css', {
55-
'includeMode': 'implicit'
67+
'includeMode': 'implicit',
68+
'spritesmithOptions': {
69+
'algorithm': 'top-down'
70+
}
5671
});
5772
});
5873

5974
// Only declarations with explicit `includeMode` true meta data, will be sprited
6075
it('should work in explicit mode `options.includeMode`', function() {
6176
return compareSpriterResultsToExpected('test/test-css/overall.css', 'test/test-css/expected/overall-include-explicit.css', {
62-
'includeMode': 'explicit'
77+
'includeMode': 'explicit',
78+
'spritesmithOptions': {
79+
'algorithm': 'top-down'
80+
}
6381
});
6482
});
6583

@@ -206,6 +224,7 @@ describe('gulp-css-spriter', function() {
206224
options = options || {};
207225

208226
var spriterPromise = spriterTest(options, actualPath).then(function(result) {
227+
console.log(String(result.contents));
209228
return String(result.contents);
210229
});
211230

0 commit comments

Comments
 (0)