Skip to content

Commit 6089d18

Browse files
committed
Linting/formatting
1 parent ad2e1cb commit 6089d18

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

test/image/compare_pixels_test.js

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,24 @@ var getImagePaths = require('./assets/get_image_paths');
3535
var argv = minimist(process.argv.slice(2), {});
3636

3737
// If no pattern is provided, all mocks are compared
38-
if(argv._.length === 0) {
38+
if (argv._.length === 0) {
3939
argv._.push('');
4040
}
4141

4242
// Build list of mocks to compare
4343
var allMockList = [];
4444
var mathjax3;
4545
var virtualWebgl = false;
46-
argv._.forEach(function(pattern) {
47-
if(pattern === 'mathjax3') {
46+
argv._.forEach(function (pattern) {
47+
if (pattern === 'mathjax3') {
4848
mathjax3 = true;
49-
} else if(pattern === 'virtual-webgl') {
49+
} else if (pattern === 'virtual-webgl') {
5050
virtualWebgl = true;
5151
allMockList = getMockList('');
5252
} else {
5353
var mockList = getMockList(pattern);
5454

55-
if(mockList.length === 0) {
55+
if (mockList.length === 0) {
5656
throw 'No mocks found with pattern ' + pattern;
5757
}
5858

@@ -66,16 +66,16 @@ var blacklist = [
6666
'map_predefined-styles2',
6767
'map_scattercluster',
6868
'map_fonts-supported-open-sans',
69-
'map_fonts-supported-open-sans-weight',
69+
'map_fonts-supported-open-sans-weight'
7070
];
7171

72-
if(virtualWebgl) {
73-
allMockList = allMockList.filter(function(a) {
72+
if (virtualWebgl) {
73+
allMockList = allMockList.filter(function (a) {
7474
return a.slice(0, 2) === 'gl';
7575
});
7676
}
7777

78-
if(mathjax3) {
78+
if (mathjax3) {
7979
allMockList = [
8080
'legend_mathjax_title_and_items',
8181
'mathjax',
@@ -84,7 +84,7 @@ if(mathjax3) {
8484
'table_plain_birds',
8585
'table_wrapped_birds',
8686
'ternary-mathjax',
87-
'ternary-mathjax-title-place-subtitle',
87+
'ternary-mathjax-title-place-subtitle'
8888
];
8989
}
9090

@@ -96,43 +96,42 @@ allMockList = allMockList.filter(unique);
9696

9797
var skipped = [];
9898
var failed = [];
99-
var fail = function(mockName) {
100-
if(failed.indexOf(mockName) === -1) {
99+
var fail = function (mockName) {
100+
if (failed.indexOf(mockName) === -1) {
101101
failed.push(mockName);
102102
}
103103
};
104104

105-
for(var i = 0; i < allMockList.length; i++) {
105+
for (var i = 0; i < allMockList.length; i++) {
106106
var mockName = allMockList[i];
107107

108108
// skip blacklist
109-
if(blacklist.indexOf(mockName) !== -1) continue;
109+
if (blacklist.indexOf(mockName) !== -1) continue;
110110

111-
var flakyMap = [
112-
// more flaky
113-
'map_density0-legend',
114-
'map_osm-style',
115-
'map_predefined-styles1',
116-
'map_predefined-styles2',
117-
].indexOf(mockName) !== -1;
111+
var flakyMap =
112+
[
113+
// more flaky
114+
'map_density0-legend',
115+
'map_osm-style',
116+
'map_predefined-styles1',
117+
'map_predefined-styles2'
118+
].indexOf(mockName) !== -1;
118119

119-
var otherFlaky = [
120-
// list flaky mocks other than maps:
121-
'gl3d_bunny-hull'
122-
].indexOf(mockName) !== -1;
120+
var otherFlaky =
121+
[
122+
// list flaky mocks other than maps:
123+
'gl3d_bunny-hull'
124+
].indexOf(mockName) !== -1;
123125

124-
var threshold =
125-
flakyMap ? 1 :
126-
otherFlaky ? 0.15 :
127-
0;
126+
var threshold = flakyMap ? 1 : otherFlaky ? 0.15 : 0;
128127

129-
if(mathjax3) mockName = 'mathjax3___' + mockName;
128+
if (mathjax3) mockName = 'mathjax3___' + mockName;
130129

131130
var imagePaths = getImagePaths(mockName);
132131
var base = imagePaths.baseline;
133132
var test = imagePaths.test;
134133

135-
if(!common.doesFileExist(test) && !mathjax3) {
134+
if (!common.doesFileExist(test) && !mathjax3) {
136135
console.log('- skip:', mockName);
137136
skipped.push(mockName);
138137
continue;
@@ -146,15 +145,15 @@ for(var i = 0; i < allMockList.length; i++) {
146145
key = 'width';
147146
s0 = img0[key];
148147
s1 = img0[key];
149-
if(s0 !== s1) {
148+
if (s0 !== s1) {
150149
console.error(key + 's do not match: ' + s0 + ' vs ' + s1);
151150
fail(mockName);
152151
}
153152

154153
key = 'height';
155154
s0 = img0[key];
156155
s1 = img0[key];
157-
if(s0 !== s1) {
156+
if (s0 !== s1) {
158157
console.error(key + 's do not match: ' + s0 + ' vs ' + s1);
159158
fail(mockName);
160159
}
@@ -167,24 +166,27 @@ for(var i = 0; i < allMockList.length; i++) {
167166
height: height
168167
});
169168

170-
if(virtualWebgl) {
169+
if (virtualWebgl) {
171170
threshold = Math.max(0.4, threshold);
172-
if([
173-
'gl3d_ibm-plot',
174-
'gl3d_isosurface_2surfaces-checker_spaceframe',
175-
'gl3d_opacity-scaling-spikes',
176-
'gl3d_cone-wind',
177-
'gl3d_isosurface_math',
178-
'gl3d_scatter3d-blank-text',
179-
'gl3d_mesh3d_surface3d_scatter3d_line3d_error3d_log_reversed_ranges'
180-
].indexOf(mockName) !== -1) threshold = 0.7;
171+
if (
172+
[
173+
'gl3d_ibm-plot',
174+
'gl3d_isosurface_2surfaces-checker_spaceframe',
175+
'gl3d_opacity-scaling-spikes',
176+
'gl3d_cone-wind',
177+
'gl3d_isosurface_math',
178+
'gl3d_scatter3d-blank-text',
179+
'gl3d_mesh3d_surface3d_scatter3d_line3d_error3d_log_reversed_ranges'
180+
].indexOf(mockName) !== -1
181+
)
182+
threshold = 0.7;
181183
}
182184

183185
var numDiffPixels = pixelmatch(img0.data, img1.data, diff.data, width, height, {
184186
threshold: threshold
185187
});
186188

187-
if(numDiffPixels) {
189+
if (numDiffPixels) {
188190
fs.writeFileSync(imagePaths.diff, PNG.sync.write(diff));
189191

190192
console.error('pixels do not match: ' + numDiffPixels);
@@ -195,9 +197,13 @@ for(var i = 0; i < allMockList.length; i++) {
195197
}
196198
}
197199

198-
if(failed.length || skipped.length) {
199-
throw JSON.stringify({
200-
failed: failed,
201-
skipped: skipped
202-
}, null, 2);
200+
if (failed.length || skipped.length) {
201+
throw JSON.stringify(
202+
{
203+
failed: failed,
204+
skipped: skipped
205+
},
206+
null,
207+
2
208+
);
203209
}

0 commit comments

Comments
 (0)