Skip to content

Commit 6a595b6

Browse files
committed
treemap jasmine tests
1 parent 6cc8590 commit 6a595b6

File tree

4 files changed

+1077
-4
lines changed

4 files changed

+1077
-4
lines changed

tasks/test_syntax.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ function assertSrcContents() {
140140
} else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) {
141141
logs.push(file + ' : contains .' + lastPart + ' (IE failure)');
142142
} else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) {
143-
// add special case for sunburst where we use 'children'
143+
// add special case for sunburst and treemap where we use 'children'
144144
// off the d3-hierarchy output
145145
var dirParts = path.dirname(file).split(path.sep);
146-
var isSunburstFile = dirParts[dirParts.length - 1] === 'sunburst';
147-
var isLinkedToObject = ['pt', 'd', 'parent'].indexOf(parts[parts.length - 2]) !== -1;
148-
if(!(isSunburstFile && isLinkedToObject)) {
146+
var filename = dirParts[dirParts.length - 1];
147+
var isSunburstOrTreemap =
148+
filename === 'sunburst' ||
149+
filename === 'treemap';
150+
var isLinkedToObject = ['pt', 'd', 'parent', 'node'].indexOf(parts[parts.length - 2]) !== -1;
151+
if(!(isSunburstOrTreemap && isLinkedToObject)) {
149152
logs.push(file + ' : contains .' + lastPart + ' (IE failure in SVG)');
150153
}
151154
} else if(FF_BLACK_LIST.indexOf(lastPart) !== -1) {

test/jasmine/assets/mock_lists.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var svgMockList = [
3333
['range_slider_multiple', require('@mocks/range_slider_multiple.json')],
3434
['sankey_energy', require('@mocks/sankey_energy.json')],
3535
['sunburst_coffee', require('@mocks/sunburst_coffee.json')],
36+
['treemap_coffee', require('@mocks/treemap_coffee.json')],
3637
['parcats_bad-displayindex', require('@mocks/parcats_bad-displayindex.json')],
3738
['scattercarpet', require('@mocks/scattercarpet.json')],
3839
['shapes', require('@mocks/shapes.json')],

test/jasmine/tests/plot_api_react_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,42 @@ describe('Plotly.react and uirevision attributes', function() {
19011901
.catch(failTest)
19021902
.then(done);
19031903
});
1904+
1905+
it('preserves treemap level changes', function(done) {
1906+
function assertLevel(msg, exp) {
1907+
expect(gd._fullData[0].level).toBe(exp, msg);
1908+
}
1909+
1910+
Plotly.react(gd, [{
1911+
type: 'treemap',
1912+
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
1913+
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
1914+
uirevision: 1
1915+
}])
1916+
.then(function() {
1917+
assertLevel('no set level at start', undefined);
1918+
})
1919+
.then(function() {
1920+
var nodeSeth = d3.select('.slice:nth-child(2)').node();
1921+
mouseEvent('click', 0, 0, {element: nodeSeth});
1922+
})
1923+
.then(function() {
1924+
assertLevel('after clicking on Seth sector', 'Seth');
1925+
})
1926+
.then(function() {
1927+
return Plotly.react(gd, [{
1928+
type: 'treemap',
1929+
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'],
1930+
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'],
1931+
uirevision: 1
1932+
}]);
1933+
})
1934+
.then(function() {
1935+
assertLevel('after reacting with new data, but with same uirevision', 'Seth');
1936+
})
1937+
.catch(failTest)
1938+
.then(done);
1939+
});
19041940
});
19051941

19061942
describe('Test Plotly.react + interactions under uirevision:', function() {

0 commit comments

Comments
 (0)