Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5b1929

Browse files
committed
dry mapbox test suite
1 parent 2955f9b commit b5b1929

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

test/jasmine/tests/mapbox_test.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ var mouseEvent = require('../assets/mouse_event');
1111
var customMatchers = require('../assets/custom_matchers');
1212

1313
var MAPBOX_ACCESS_TOKEN = require('@build/credentials.json').MAPBOX_ACCESS_TOKEN;
14+
var TRANSITION_DELAY = 500;
1415

1516
var noop = function() {};
1617

18+
Plotly.setPlotConfig({
19+
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
20+
});
21+
22+
1723
describe('mapbox defaults', function() {
1824
'use strict';
1925

@@ -244,8 +250,6 @@ describe('mapbox plots', function() {
244250

245251
it('should be able to restyle', function(done) {
246252
function assertMarkerColor(expectations) {
247-
var TRANSITION_DELAY = 500;
248-
249253
return new Promise(function(resolve) {
250254
setTimeout(function() {
251255
var colors = getStyle(gd, 'circle', 'circle-color');
@@ -505,23 +509,34 @@ describe('mapbox plots', function() {
505509
map = subplot.map;
506510

507511
var sources = map.style.sources,
508-
layers = map.style._layers;
512+
layers = map.style._layers,
513+
uid = subplot.uid;
509514

510-
var plotlySources = Object.keys(sources).filter(function(k) {
515+
var traceSources = Object.keys(sources).filter(function(k) {
511516
return k.indexOf('-source-') !== -1;
512517
});
513518

514-
var plotlyLayers = Object.keys(layers).filter(function(k) {
519+
var traceLayers = Object.keys(layers).filter(function(k) {
515520
return k.indexOf('-layer-') !== -1;
516521
});
517522

523+
var layoutSources = Object.keys(sources).filter(function(k) {
524+
return k.indexOf(uid) !== -1;
525+
});
526+
527+
var layoutLayers = Object.keys(layers).filter(function(k) {
528+
return k.indexOf(uid) !== -1;
529+
});
530+
518531
return {
519532
map: map,
520533
div: subplot.div,
521534
sources: sources,
522535
layers: layers,
523-
plotlySources: plotlySources,
524-
plotlyLayers: plotlyLayers,
536+
traceSources: traceSources,
537+
traceLayers: traceLayers,
538+
layoutSources: layoutSources,
539+
layoutLayers: layoutLayers,
525540
center: map.getCenter(),
526541
zoom: map.getZoom(),
527542
style: map.getStyle()
@@ -538,7 +553,7 @@ describe('mapbox plots', function() {
538553
modes.forEach(function(mode) {
539554
var cntPerMode = 0;
540555

541-
mapInfo.plotlyLayers.forEach(function(l) {
556+
mapInfo.traceLayers.forEach(function(l) {
542557
var info = mapInfo.layers[l];
543558

544559
if(l.indexOf(mode) === -1) return;
@@ -562,7 +577,7 @@ describe('mapbox plots', function() {
562577
var mapInfo = getMapInfo(gd),
563578
values = [];
564579

565-
mapInfo.plotlyLayers.forEach(function(l) {
580+
mapInfo.traceLayers.forEach(function(l) {
566581
var info = mapInfo.layers[l];
567582

568583
if(l.indexOf(mode) === -1) return;
@@ -577,7 +592,7 @@ describe('mapbox plots', function() {
577592
var mapInfo = getMapInfo(gd),
578593
out = [];
579594

580-
mapInfo.plotlySources.forEach(function(s) {
595+
mapInfo.traceSources.forEach(function(s) {
581596
var info = mapInfo.sources[s];
582597

583598
if(s.indexOf(mode) === -1) return;

0 commit comments

Comments
 (0)