Skip to content

Commit 6dd25e2

Browse files
committed
add mapbox to image tests
1 parent 7cf69e2 commit 6dd25e2

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed

test/jasmine/tests/mapbox_test.js

+73
Original file line numberDiff line numberDiff line change
@@ -964,5 +964,78 @@ describe('@noCI, mapbox plots', function() {
964964
}, MOUSE_DELAY);
965965
});
966966
}
967+
});
968+
969+
describe('@noCI, mapbox toImage', function() {
970+
var MINIMUM_LENGTH = 1e5;
971+
972+
var gd;
973+
974+
beforeEach(function() {
975+
gd = createGraphDiv();
976+
});
977+
978+
afterEach(function() {
979+
Plotly.purge(gd);
980+
Plotly.setPlotConfig({ mapboxAccessToken: null });
981+
destroyGraphDiv();
982+
});
983+
984+
it('should generate image data with global credentials', function(done) {
985+
Plotly.setPlotConfig({
986+
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
987+
});
988+
989+
Plotly.newPlot(gd, [{
990+
type: 'scattermapbox',
991+
lon: [0, 10, 20],
992+
lat: [-10, 10, -10]
993+
}])
994+
.then(function() {
995+
return Plotly.toImage(gd);
996+
})
997+
.then(function(imgData) {
998+
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
999+
})
1000+
.catch(failTest)
1001+
.then(done);
1002+
}, LONG_TIMEOUT_INTERVAL);
1003+
1004+
it('should generate image data with config credentials', function(done) {
1005+
Plotly.newPlot(gd, [{
1006+
type: 'scattermapbox',
1007+
lon: [0, 10, 20],
1008+
lat: [-10, 10, -10]
1009+
}], {}, {
1010+
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
1011+
})
1012+
.then(function() {
1013+
return Plotly.toImage(gd);
1014+
})
1015+
.then(function(imgData) {
1016+
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
1017+
})
1018+
.catch(failTest)
1019+
.then(done);
1020+
}, LONG_TIMEOUT_INTERVAL);
9671021

1022+
it('should generate image data with layout credentials', function(done) {
1023+
Plotly.newPlot(gd, [{
1024+
type: 'scattermapbox',
1025+
lon: [0, 10, 20],
1026+
lat: [-10, 10, -10]
1027+
}], {
1028+
mapbox: {
1029+
accesstoken: MAPBOX_ACCESS_TOKEN
1030+
}
1031+
})
1032+
.then(function() {
1033+
return Plotly.toImage(gd);
1034+
})
1035+
.then(function(imgData) {
1036+
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
1037+
})
1038+
.catch(failTest)
1039+
.then(done);
1040+
}, LONG_TIMEOUT_INTERVAL);
9681041
});

test/jasmine/tests/scattermapbox_test.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ function move(fromX, fromY, toX, toY, delay) {
2424
});
2525
}
2626

27-
Plotly.setPlotConfig({
28-
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
29-
});
30-
31-
3227
describe('scattermapbox defaults', function() {
3328
'use strict';
3429

@@ -341,6 +336,10 @@ describe('@noCI scattermapbox hover', function() {
341336
beforeAll(function(done) {
342337
jasmine.addMatchers(customMatchers);
343338

339+
Plotly.setPlotConfig({
340+
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
341+
});
342+
344343
gd = createGraphDiv();
345344

346345
var data = [{
@@ -520,6 +519,10 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
520519
beforeAll(function(done) {
521520
jasmine.addMatchers(customMatchers);
522521

522+
Plotly.setPlotConfig({
523+
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
524+
});
525+
523526
gd = createGraphDiv();
524527
mockCopy = Lib.extendDeep({}, mock);
525528

0 commit comments

Comments
 (0)