Skip to content

Make citest-jasmine pass locally #1211

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 9 commits into from
Dec 1, 2016
7 changes: 6 additions & 1 deletion src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {

// keep track of pan / zoom in user layout and emit relayout event
map.on('moveend', function(eventData) {
if(!self.map) return;

var view = self.getView();

opts._input.center = opts.center = view.center;
Expand Down Expand Up @@ -358,7 +360,10 @@ proto.updateLayers = function() {
};

proto.destroy = function() {
if(this.map) this.map.remove();
if(this.map) {
this.map.remove();
this.map = null;
}
this.container.removeChild(this.div);
};

Expand Down
2 changes: 1 addition & 1 deletion src/traces/heatmapgl/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'use strict';


var heatmapAttrs = require('../scatter/attributes');
var heatmapAttrs = require('../heatmap/attributes');
var colorscaleAttrs = require('../../components/colorscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');

Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/karma.ciconf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function func(config) {

func.defaultConfig.autoWatch = false;

func.defaultConfig.browsers = ['Firefox'];
func.defaultConfig.browsers = ['Firefox_WindowSized'];

config.set(func.defaultConfig);
}
Expand Down
6 changes: 5 additions & 1 deletion test/jasmine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ func.defaultConfig = {
browsers: ['Chrome_WindowSized'],

// custom browser options
// window-size values came from observing default size
customLaunchers: {
Chrome_WindowSized: {
base: 'Chrome',
// window-size values came from observing default size
flags: ['--window-size=1035,617', '--ignore-gpu-blacklist']
},
Firefox_WindowSized: {
base: 'Firefox',
flags: ['--width=1035', '--height=617']
}
},

Expand Down
18 changes: 6 additions & 12 deletions test/jasmine/tests/download_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var textchartMock = require('@mocks/text_chart_arrays.json');

var LONG_TIMEOUT_INTERVAL = 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL;

describe('Plotly.downloadImage', function() {
'use strict';
var gd;
var originalTimeout;

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

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

// downloadImage can take a little longer
// so give it a little more time to finish
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});

afterEach(function() {
destroyGraphDiv();
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});

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

it('should create link, remove link, accept options', function(done) {
downloadTest(gd, 'jpeg', done);
});
}, LONG_TIMEOUT_INTERVAL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See jasmine/jasmine@68ba5b6 for example.


it('should create link, remove link, accept options', function(done) {
downloadTest(gd, 'png', done);
});
}, LONG_TIMEOUT_INTERVAL);

it('should create link, remove link, accept options', function(done) {
checkWebp(function(supported) {
Expand All @@ -59,12 +54,11 @@ describe('Plotly.downloadImage', function() {
done();
}
});

});
}, LONG_TIMEOUT_INTERVAL);

it('should create link, remove link, accept options', function(done) {
downloadTest(gd, 'svg', done);
});
}, LONG_TIMEOUT_INTERVAL);
});


Expand Down
6 changes: 3 additions & 3 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ describe('hover on fill', function() {
mock.data.forEach(function(trace) { trace.hoveron = 'fills'; });

Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(function() {
return assertLabelsCorrect([242, 142], [249.175, 133.8], 'trace 2');
return assertLabelsCorrect([242, 142], [252, 133.8], 'trace 2');
}).then(function() {
return assertLabelsCorrect([242, 292], [231.125, 210], 'trace 1');
return assertLabelsCorrect([242, 292], [233, 210], 'trace 1');
}).then(function() {
return assertLabelsCorrect([147, 252], [158.925, 248.1], 'trace 0');
}).then(done);
Expand All @@ -749,7 +749,7 @@ describe('hover on fill', function() {
}).then(function() {
return assertLabelsCorrect([237, 218], [266.75, 265], 'trace 1');
}).then(function() {
return assertLabelsCorrect([237, 251], [247.7, 254], 'trace 0');
return assertLabelsCorrect([237, 240], [247.7, 254], 'trace 0');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @alexcjohnson these cases ⬆️ were tuned for FF on CI and Chrome locally. Now, they work locally in FF and Chrome as well as FF on CI.

}).then(function() {
// zoom in to test clipping of large out-of-viewport shapes
return Plotly.relayout(gd, {
Expand Down
79 changes: 48 additions & 31 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var customMatchers = require('../assets/custom_matchers');
var MAPBOX_ACCESS_TOKEN = require('@build/credentials.json').MAPBOX_ACCESS_TOKEN;
var TRANSITION_DELAY = 500;
var MOUSE_DELAY = 100;
var LONG_TIMEOUT_INTERVAL = 5 * jasmine.DEFAULT_TIMEOUT_INTERVAL;

var noop = function() {};

Expand Down Expand Up @@ -204,7 +205,7 @@ describe('mapbox credentials', function() {
lat: [10, 20, 30]
}]);
}).toThrow(new Error(constants.noAccessTokenErrorMsg));
});
}, LONG_TIMEOUT_INTERVAL);

it('should throw error if token is invalid', function(done) {
var cnt = 0;
Expand All @@ -215,14 +216,16 @@ describe('mapbox credentials', function() {
lat: [10, 20, 30]
}], {}, {
mapboxAccessToken: dummyToken
}).catch(function(err) {
})
.catch(function(err) {
cnt++;
expect(err).toEqual(new Error(constants.mapOnErrorMsg));
}).then(function() {
})
.then(function() {
expect(cnt).toEqual(1);
done();
});
});
}, LONG_TIMEOUT_INTERVAL);

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

it('should bypass access token in mapbox layout options when config points to an Atlas server', function(done) {
var cnt = 0;
Expand All @@ -263,14 +266,16 @@ describe('mapbox credentials', function() {
}
}, {
mapboxAccessToken: ''
}).catch(function(err) {
})
.catch(function(err) {
cnt++;
expect(err).toEqual(new Error(msg));
}).then(function() {
})
.then(function() {
expect(cnt).toEqual(1);
done();
});
});
}, LONG_TIMEOUT_INTERVAL);
});

describe('mapbox plots', function() {
Expand Down Expand Up @@ -310,27 +315,31 @@ describe('mapbox plots', function() {
expect(gd._fullLayout.mapbox).toBeUndefined();

return Plotly.restyle(gd, 'visible', true);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(2);

return Plotly.restyle(gd, 'visible', 'legendonly', [1]);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(1);

return Plotly.restyle(gd, 'visible', true);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(2);

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

return Plotly.newPlot(gd, mockCopy.data, mockCopy.layout);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(1);

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

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

return Plotly.addTraces(gd, [trace]);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(2);

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

return Plotly.addTraces(gd, [trace]);
}).then(function() {
})
.then(function() {
expect(countVisibleTraces(gd, modes)).toEqual(3);

return Plotly.deleteTraces(gd, [0, 1, 2]);
}).then(function() {
})
.then(function() {
expect(gd._fullLayout.mapbox).toBeUndefined();

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

it('should be able to restyle', function(done) {
var restyleCnt = 0,
Expand Down Expand Up @@ -425,7 +437,7 @@ describe('mapbox plots', function() {
]);
})
.then(done);
});
}, LONG_TIMEOUT_INTERVAL);

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

return Plotly.relayout(gd, 'mapbox.zoom', '6');
}).then(function() {
})
.then(function() {
expect(restyleCnt).toEqual(0);
expect(relayoutCnt).toEqual(2);

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

return Plotly.relayout(gd, 'mapbox.style', 'light');
}).then(function() {
})
.then(function() {
expect(restyleCnt).toEqual(0);
expect(relayoutCnt).toEqual(3);

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

return Plotly.relayout(gd, 'mapbox.domain.x', [0, 0.5]);
}).then(function() {
})
.then(function() {
expect(restyleCnt).toEqual(0);
expect(relayoutCnt).toEqual(4);

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

return Plotly.relayout(gd, 'mapbox.domain.y[0]', 0.5);
}).then(function() {
})
.then(function() {
expect(restyleCnt).toEqual(0);
expect(relayoutCnt).toEqual(5);

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

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

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

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

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

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

return Plotly.extendTraces(gd, update, [0, 1]);
}).then(function() {
})
.then(function() {
assertDataPts([5, 5]);

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

it('should display to hover labels on mouse over', function(done) {
function assertMouseMove(pos, len) {
Expand All @@ -688,7 +705,7 @@ describe('mapbox plots', function() {
assertMouseMove(blankPos, 0).then(function() {
return assertMouseMove(pointPos, 1);
}).then(done);
});
}, LONG_TIMEOUT_INTERVAL);

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

done();
});
});
}, LONG_TIMEOUT_INTERVAL);

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

// TODO test scroll

});
}, LONG_TIMEOUT_INTERVAL);

it('should respond to click interactions by', function(done) {
var ptData;
Expand Down Expand Up @@ -828,7 +845,7 @@ describe('mapbox plots', function() {
});
})
.then(done);
});
}, LONG_TIMEOUT_INTERVAL);

function getMapInfo(gd) {
var subplot = gd._fullLayout.mapbox._subplot,
Expand Down
Loading