Skip to content

Mapbox to image context #1598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add mapbox to image tests
  • Loading branch information
etpinard committed Apr 13, 2017
commit 6dd25e2ab5f2c2f63b6f2d212ba96caf1abf23d0
73 changes: 73 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,5 +964,78 @@ describe('@noCI, mapbox plots', function() {
}, MOUSE_DELAY);
});
}
});

describe('@noCI, mapbox toImage', function() {
var MINIMUM_LENGTH = 1e5;

var gd;

beforeEach(function() {
gd = createGraphDiv();
});

afterEach(function() {
Plotly.purge(gd);
Plotly.setPlotConfig({ mapboxAccessToken: null });
destroyGraphDiv();
});

it('should generate image data with global credentials', function(done) {
Plotly.setPlotConfig({
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
});

Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}])
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('should generate image data with config credentials', function(done) {
Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}], {}, {
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
})
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('should generate image data with layout credentials', function(done) {
Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}], {
mapbox: {
accesstoken: MAPBOX_ACCESS_TOKEN
}
})
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);
});
13 changes: 8 additions & 5 deletions test/jasmine/tests/scattermapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ function move(fromX, fromY, toX, toY, delay) {
});
}

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});


describe('scattermapbox defaults', function() {
'use strict';

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

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});

gd = createGraphDiv();

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

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});

gd = createGraphDiv();
mockCopy = Lib.extendDeep({}, mock);

Expand Down