Skip to content

Commit 2dbdf07

Browse files
authored
Merge pull request #1211 from plotly/fix-citest-jasmine
Make citest-jasmine pass locally
2 parents c25d57b + caea87a commit 2dbdf07

File tree

8 files changed

+79
-55
lines changed

8 files changed

+79
-55
lines changed

src/plots/mapbox/mapbox.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
126126

127127
// keep track of pan / zoom in user layout and emit relayout event
128128
map.on('moveend', function(eventData) {
129+
if(!self.map) return;
130+
129131
var view = self.getView();
130132

131133
opts._input.center = opts.center = view.center;
@@ -358,7 +360,10 @@ proto.updateLayers = function() {
358360
};
359361

360362
proto.destroy = function() {
361-
if(this.map) this.map.remove();
363+
if(this.map) {
364+
this.map.remove();
365+
this.map = null;
366+
}
362367
this.container.removeChild(this.div);
363368
};
364369

src/traces/heatmapgl/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'use strict';
1010

1111

12-
var heatmapAttrs = require('../scatter/attributes');
12+
var heatmapAttrs = require('../heatmap/attributes');
1313
var colorscaleAttrs = require('../../components/colorscale/attributes');
1414
var colorbarAttrs = require('../../components/colorbar/attributes');
1515

test/jasmine/karma.ciconf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function func(config) {
3333

3434
func.defaultConfig.autoWatch = false;
3535

36-
func.defaultConfig.browsers = ['Firefox'];
36+
func.defaultConfig.browsers = ['Firefox_WindowSized'];
3737

3838
config.set(func.defaultConfig);
3939
}

test/jasmine/karma.conf.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ func.defaultConfig = {
8282
browsers: ['Chrome_WindowSized'],
8383

8484
// custom browser options
85+
// window-size values came from observing default size
8586
customLaunchers: {
8687
Chrome_WindowSized: {
8788
base: 'Chrome',
88-
// window-size values came from observing default size
8989
flags: ['--window-size=1035,617', '--ignore-gpu-blacklist']
90+
},
91+
Firefox_WindowSized: {
92+
base: 'Firefox',
93+
flags: ['--width=1035', '--height=617']
9094
}
9195
},
9296

test/jasmine/tests/download_test.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ var createGraphDiv = require('../assets/create_graph_div');
33
var destroyGraphDiv = require('../assets/destroy_graph_div');
44
var textchartMock = require('@mocks/text_chart_arrays.json');
55

6+
var LONG_TIMEOUT_INTERVAL = 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL;
7+
68
describe('Plotly.downloadImage', function() {
79
'use strict';
810
var gd;
9-
var originalTimeout;
1011

1112
// override click handler on createElement
1213
// so these tests will not actually
@@ -27,16 +28,10 @@ describe('Plotly.downloadImage', function() {
2728

2829
beforeEach(function() {
2930
gd = createGraphDiv();
30-
31-
// downloadImage can take a little longer
32-
// so give it a little more time to finish
33-
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
34-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
3531
});
3632

3733
afterEach(function() {
3834
destroyGraphDiv();
39-
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
4035
});
4136

4237
it('should be attached to Plotly', function() {
@@ -45,11 +40,11 @@ describe('Plotly.downloadImage', function() {
4540

4641
it('should create link, remove link, accept options', function(done) {
4742
downloadTest(gd, 'jpeg', done);
48-
});
43+
}, LONG_TIMEOUT_INTERVAL);
4944

5045
it('should create link, remove link, accept options', function(done) {
5146
downloadTest(gd, 'png', done);
52-
});
47+
}, LONG_TIMEOUT_INTERVAL);
5348

5449
it('should create link, remove link, accept options', function(done) {
5550
checkWebp(function(supported) {
@@ -59,12 +54,11 @@ describe('Plotly.downloadImage', function() {
5954
done();
6055
}
6156
});
62-
63-
});
57+
}, LONG_TIMEOUT_INTERVAL);
6458

6559
it('should create link, remove link, accept options', function(done) {
6660
downloadTest(gd, 'svg', done);
67-
});
61+
}, LONG_TIMEOUT_INTERVAL);
6862
});
6963

7064

test/jasmine/tests/hover_label_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,9 @@ describe('hover on fill', function() {
726726
mock.data.forEach(function(trace) { trace.hoveron = 'fills'; });
727727

728728
Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(function() {
729-
return assertLabelsCorrect([242, 142], [249.175, 133.8], 'trace 2');
729+
return assertLabelsCorrect([242, 142], [252, 133.8], 'trace 2');
730730
}).then(function() {
731-
return assertLabelsCorrect([242, 292], [231.125, 210], 'trace 1');
731+
return assertLabelsCorrect([242, 292], [233, 210], 'trace 1');
732732
}).then(function() {
733733
return assertLabelsCorrect([147, 252], [158.925, 248.1], 'trace 0');
734734
}).then(done);
@@ -749,7 +749,7 @@ describe('hover on fill', function() {
749749
}).then(function() {
750750
return assertLabelsCorrect([237, 218], [266.75, 265], 'trace 1');
751751
}).then(function() {
752-
return assertLabelsCorrect([237, 251], [247.7, 254], 'trace 0');
752+
return assertLabelsCorrect([237, 240], [247.7, 254], 'trace 0');
753753
}).then(function() {
754754
// zoom in to test clipping of large out-of-viewport shapes
755755
return Plotly.relayout(gd, {

test/jasmine/tests/mapbox_test.js

+48-31
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var customMatchers = require('../assets/custom_matchers');
1414
var MAPBOX_ACCESS_TOKEN = require('@build/credentials.json').MAPBOX_ACCESS_TOKEN;
1515
var TRANSITION_DELAY = 500;
1616
var MOUSE_DELAY = 100;
17+
var LONG_TIMEOUT_INTERVAL = 5 * jasmine.DEFAULT_TIMEOUT_INTERVAL;
1718

1819
var noop = function() {};
1920

@@ -204,7 +205,7 @@ describe('mapbox credentials', function() {
204205
lat: [10, 20, 30]
205206
}]);
206207
}).toThrow(new Error(constants.noAccessTokenErrorMsg));
207-
});
208+
}, LONG_TIMEOUT_INTERVAL);
208209

209210
it('should throw error if token is invalid', function(done) {
210211
var cnt = 0;
@@ -215,14 +216,16 @@ describe('mapbox credentials', function() {
215216
lat: [10, 20, 30]
216217
}], {}, {
217218
mapboxAccessToken: dummyToken
218-
}).catch(function(err) {
219+
})
220+
.catch(function(err) {
219221
cnt++;
220222
expect(err).toEqual(new Error(constants.mapOnErrorMsg));
221-
}).then(function() {
223+
})
224+
.then(function() {
222225
expect(cnt).toEqual(1);
223226
done();
224227
});
225-
});
228+
}, LONG_TIMEOUT_INTERVAL);
226229

227230
it('should use access token in mapbox layout options if present', function(done) {
228231
var cnt = 0;
@@ -244,7 +247,7 @@ describe('mapbox credentials', function() {
244247
expect(gd._fullLayout.mapbox.accesstoken).toEqual(MAPBOX_ACCESS_TOKEN);
245248
done();
246249
});
247-
});
250+
}, LONG_TIMEOUT_INTERVAL);
248251

249252
it('should bypass access token in mapbox layout options when config points to an Atlas server', function(done) {
250253
var cnt = 0;
@@ -263,14 +266,16 @@ describe('mapbox credentials', function() {
263266
}
264267
}, {
265268
mapboxAccessToken: ''
266-
}).catch(function(err) {
269+
})
270+
.catch(function(err) {
267271
cnt++;
268272
expect(err).toEqual(new Error(msg));
269-
}).then(function() {
273+
})
274+
.then(function() {
270275
expect(cnt).toEqual(1);
271276
done();
272277
});
273-
});
278+
}, LONG_TIMEOUT_INTERVAL);
274279
});
275280

276281
describe('mapbox plots', function() {
@@ -310,27 +315,31 @@ describe('mapbox plots', function() {
310315
expect(gd._fullLayout.mapbox).toBeUndefined();
311316

312317
return Plotly.restyle(gd, 'visible', true);
313-
}).then(function() {
318+
})
319+
.then(function() {
314320
expect(countVisibleTraces(gd, modes)).toEqual(2);
315321

316322
return Plotly.restyle(gd, 'visible', 'legendonly', [1]);
317-
}).then(function() {
323+
})
324+
.then(function() {
318325
expect(countVisibleTraces(gd, modes)).toEqual(1);
319326

320327
return Plotly.restyle(gd, 'visible', true);
321-
}).then(function() {
328+
})
329+
.then(function() {
322330
expect(countVisibleTraces(gd, modes)).toEqual(2);
323331

324332
var mockCopy = Lib.extendDeep({}, mock);
325333
mockCopy.data[0].visible = false;
326334

327335
return Plotly.newPlot(gd, mockCopy.data, mockCopy.layout);
328-
}).then(function() {
336+
})
337+
.then(function() {
329338
expect(countVisibleTraces(gd, modes)).toEqual(1);
330339

331340
done();
332341
});
333-
});
342+
}, LONG_TIMEOUT_INTERVAL);
334343

335344
it('should be able to delete and add traces', function(done) {
336345
var modes = ['line', 'circle'];
@@ -348,7 +357,8 @@ describe('mapbox plots', function() {
348357
};
349358

350359
return Plotly.addTraces(gd, [trace]);
351-
}).then(function() {
360+
})
361+
.then(function() {
352362
expect(countVisibleTraces(gd, modes)).toEqual(2);
353363

354364
var trace = {
@@ -359,16 +369,18 @@ describe('mapbox plots', function() {
359369
};
360370

361371
return Plotly.addTraces(gd, [trace]);
362-
}).then(function() {
372+
})
373+
.then(function() {
363374
expect(countVisibleTraces(gd, modes)).toEqual(3);
364375

365376
return Plotly.deleteTraces(gd, [0, 1, 2]);
366-
}).then(function() {
377+
})
378+
.then(function() {
367379
expect(gd._fullLayout.mapbox).toBeUndefined();
368380

369381
done();
370382
});
371-
});
383+
}, LONG_TIMEOUT_INTERVAL);
372384

373385
it('should be able to restyle', function(done) {
374386
var restyleCnt = 0,
@@ -425,7 +437,7 @@ describe('mapbox plots', function() {
425437
]);
426438
})
427439
.then(done);
428-
});
440+
}, LONG_TIMEOUT_INTERVAL);
429441

430442
it('should be able to relayout', function(done) {
431443
var restyleCnt = 0,
@@ -462,36 +474,40 @@ describe('mapbox plots', function() {
462474
assertLayout('Mapbox Dark', [0, 0], 1.234, [80, 100, 908, 270]);
463475

464476
return Plotly.relayout(gd, 'mapbox.zoom', '6');
465-
}).then(function() {
477+
})
478+
.then(function() {
466479
expect(restyleCnt).toEqual(0);
467480
expect(relayoutCnt).toEqual(2);
468481

469482
assertLayout('Mapbox Dark', [0, 0], 6, [80, 100, 908, 270]);
470483

471484
return Plotly.relayout(gd, 'mapbox.style', 'light');
472-
}).then(function() {
485+
})
486+
.then(function() {
473487
expect(restyleCnt).toEqual(0);
474488
expect(relayoutCnt).toEqual(3);
475489

476490
assertLayout('Mapbox Light', [0, 0], 6, [80, 100, 908, 270]);
477491

478492
return Plotly.relayout(gd, 'mapbox.domain.x', [0, 0.5]);
479-
}).then(function() {
493+
})
494+
.then(function() {
480495
expect(restyleCnt).toEqual(0);
481496
expect(relayoutCnt).toEqual(4);
482497

483498
assertLayout('Mapbox Light', [0, 0], 6, [80, 100, 454, 270]);
484499

485500
return Plotly.relayout(gd, 'mapbox.domain.y[0]', 0.5);
486-
}).then(function() {
501+
})
502+
.then(function() {
487503
expect(restyleCnt).toEqual(0);
488504
expect(relayoutCnt).toEqual(5);
489505

490506
assertLayout('Mapbox Light', [0, 0], 6, [80, 100, 454, 135]);
491507

492508
done();
493509
});
494-
});
510+
}, LONG_TIMEOUT_INTERVAL);
495511

496512
it('should be able to add, update and remove layers', function(done) {
497513
var mockWithLayers = require('@mocks/mapbox_layers');
@@ -623,7 +639,7 @@ describe('mapbox plots', function() {
623639

624640
done();
625641
});
626-
});
642+
}, LONG_TIMEOUT_INTERVAL);
627643

628644
it('should be able to update the access token', function(done) {
629645
Plotly.relayout(gd, 'mapbox.accesstoken', 'wont-work').catch(function(err) {
@@ -637,7 +653,7 @@ describe('mapbox plots', function() {
637653
expect(gd._promises.length).toEqual(0);
638654
done();
639655
});
640-
});
656+
}, LONG_TIMEOUT_INTERVAL);
641657

642658
it('should be able to update traces', function(done) {
643659
function assertDataPts(lengths) {
@@ -669,12 +685,13 @@ describe('mapbox plots', function() {
669685
};
670686

671687
return Plotly.extendTraces(gd, update, [0, 1]);
672-
}).then(function() {
688+
})
689+
.then(function() {
673690
assertDataPts([5, 5]);
674691

675692
done();
676693
});
677-
});
694+
}, LONG_TIMEOUT_INTERVAL);
678695

679696
it('should display to hover labels on mouse over', function(done) {
680697
function assertMouseMove(pos, len) {
@@ -688,7 +705,7 @@ describe('mapbox plots', function() {
688705
assertMouseMove(blankPos, 0).then(function() {
689706
return assertMouseMove(pointPos, 1);
690707
}).then(done);
691-
});
708+
}, LONG_TIMEOUT_INTERVAL);
692709

693710
it('should respond to hover interactions by', function(done) {
694711
var hoverCnt = 0,
@@ -736,7 +753,7 @@ describe('mapbox plots', function() {
736753

737754
done();
738755
});
739-
});
756+
}, LONG_TIMEOUT_INTERVAL);
740757

741758
it('should respond drag / scroll interactions', function(done) {
742759
var relayoutCnt = 0,
@@ -795,7 +812,7 @@ describe('mapbox plots', function() {
795812

796813
// TODO test scroll
797814

798-
});
815+
}, LONG_TIMEOUT_INTERVAL);
799816

800817
it('should respond to click interactions by', function(done) {
801818
var ptData;
@@ -828,7 +845,7 @@ describe('mapbox plots', function() {
828845
});
829846
})
830847
.then(done);
831-
});
848+
}, LONG_TIMEOUT_INTERVAL);
832849

833850
function getMapInfo(gd) {
834851
var subplot = gd._fullLayout.mapbox._subplot,

0 commit comments

Comments
 (0)