Skip to content

Commit 19c7a61

Browse files
etpinardarchmoj
authored andcommitted
[wip] add test for sunburst tween edge cases
1 parent 2405ba4 commit 19c7a61

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

test/jasmine/tests/sunburst_test.js

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,13 @@ describe('Test sunburst tweening:', function() {
967967

968968
afterEach(destroyGraphDiv);
969969

970-
function _run(gd, v) {
970+
function _reset() {
971971
pathTweenFnLookup = {};
972972
textTweenFnLookup = {};
973+
}
973974

975+
function _run(gd, v) {
976+
_reset();
974977
click(gd, v)();
975978

976979
// 1 second more than the click transition duration
@@ -1002,7 +1005,7 @@ describe('Test sunburst tweening:', function() {
10021005
expect(actual).toBe(trim(exp), msg + ' | node ' + id + ' @t=' + t);
10031006
}
10041007

1005-
it('should tween sector exit/update (case: branch, no maxdepth)', function(done) {
1008+
it('should tween sector exit/update (case: click on branch, no maxdepth)', function(done) {
10061009
var mock = {
10071010
data: [{
10081011
type: 'sunburst',
@@ -1040,7 +1043,7 @@ describe('Test sunburst tweening:', function() {
10401043
.then(done);
10411044
});
10421045

1043-
it('should tween sector enter/update (case: entry, no maxdepth)', function(done) {
1046+
it('should tween sector enter/update (case: click on entry, no maxdepth)', function(done) {
10441047
var mock = {
10451048
data: [{
10461049
type: 'sunburst',
@@ -1079,7 +1082,7 @@ describe('Test sunburst tweening:', function() {
10791082
.then(done);
10801083
});
10811084

1082-
it('should tween sector enter/update/exit (case: entry, maxdepth=2)', function(done) {
1085+
it('should tween sector enter/update/exit (case: click on entry, maxdepth=2)', function(done) {
10831086
var mock = {
10841087
data: [{
10851088
type: 'sunburst',
@@ -1116,6 +1119,70 @@ describe('Test sunburst tweening:', function() {
11161119
.catch(failTest)
11171120
.then(done);
11181121
});
1122+
1123+
it('should tween sector enter/update/exit (case: click on entry, maxdepth=2, level=B)', function(done) {
1124+
var mock = {
1125+
data: [{
1126+
type: 'sunburst',
1127+
labels: ['Root', 'A', 'B', 'b', 'bb'],
1128+
parents: ['', 'Root', 'Root', 'B', 'b'],
1129+
maxdepth: 2,
1130+
level: 'B'
1131+
}]
1132+
};
1133+
1134+
Plotly.plot(gd, mock)
1135+
.then(_run(gd, 1))
1136+
.then(function() {
1137+
_assert('exit b radially outward and to parent sector angle', 'd', 'b',
1138+
'M350,133.75L350,100A135,1350,1,0485,235.00000000000003' +
1139+
'L451.25,235.00000000000003A101.25,101.250,1,1350,133.75Z'
1140+
);
1141+
_assert('enter new entry radially outward', 'd', 'Root',
1142+
'M350,235A0,00,1,0350,235A0,00,1,0350,235Z' +
1143+
'M383.75,235A33.75,33.750,1,1316.25,235A33.75,33.750,1,1383.75,235Z'
1144+
);
1145+
_assert('enter A counterclockwise', 'd', 'A',
1146+
'M417.5,235L485,235A135,1350,0,0350,100L350,167.5A67.5,67.50,0,1417.5,235Z'
1147+
);
1148+
_assert('update B to new position', 'd', 'B',
1149+
'M350,201.25L350,133.75A101.25,101.250,1,0451.25,235.00000000000003' +
1150+
'L383.75,235A33.75,33.750,1,1350,201.25Z'
1151+
);
1152+
})
1153+
.catch(failTest)
1154+
.then(done);
1155+
});
1156+
1157+
/*
1158+
it('should tween in sectors from new traces', function(done) {
1159+
Plotly.plot(gd, [{type: 'sunburst'}])
1160+
.then(_reset)
1161+
.then(function() {
1162+
return Plotly.animate(gd, [{
1163+
type: 'sunburst',
1164+
labels: ['Root', 'A', 'B', 'b'],
1165+
parents: ['', 'Root', 'Root', 'B']
1166+
}]);
1167+
})
1168+
.then(function() {
1169+
_assert('enter entry from theta=0', 'd', 'Root',
1170+
''
1171+
);
1172+
// _assert('enter A from theta=0', 'd', 'A',
1173+
// ''
1174+
// );
1175+
// _assert('enter B from theta=0', 'd', 'B',
1176+
// ''
1177+
// );
1178+
// _assert('enter b from theta=0', 'd', 'b',
1179+
// ''
1180+
// );
1181+
})
1182+
.catch(failTest)
1183+
.then(done);
1184+
});
1185+
*/
11191186
});
11201187

11211188
describe('Test sunburst interactions edge cases', function() {

0 commit comments

Comments
 (0)