From bb193158bfcae7dcd02d8e9153462fb278c18bfe Mon Sep 17 00:00:00 2001 From: archmoj Date: Tue, 22 Jun 2021 13:32:16 -0400 Subject: [PATCH] join react tests for sunburst, icicle and treemap --- test/jasmine/tests/plot_api_react_test.js | 134 ++++++---------------- 1 file changed, 33 insertions(+), 101 deletions(-) diff --git a/test/jasmine/tests/plot_api_react_test.js b/test/jasmine/tests/plot_api_react_test.js index 200d3d0da8f..90e54d81184 100644 --- a/test/jasmine/tests/plot_api_react_test.js +++ b/test/jasmine/tests/plot_api_react_test.js @@ -2048,109 +2048,41 @@ describe('Plotly.react and uirevision attributes', function() { _run(fig, editComponents, checkInitial, checkEdited).then(done); }); - it('preserves sunburst level changes', function(done) { - function assertLevel(msg, exp) { - expect(gd._fullData[0].level).toBe(exp, msg); - } - - Plotly.react(gd, [{ - type: 'sunburst', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'], - uirevision: 1 - }]) - .then(function() { - assertLevel('no set level at start', undefined); - }) - .then(function() { - var nodeSeth = d3Select('.slice:nth-child(2)').node(); - mouseEvent('click', 0, 0, {element: nodeSeth}); - }) - .then(function() { - assertLevel('after clicking on Seth sector', 'Seth'); - }) - .then(function() { - return Plotly.react(gd, [{ - type: 'sunburst', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'], - uirevision: 1 - }]); - }) - .then(function() { - assertLevel('after reacting with new data, but with same uirevision', 'Seth'); - }) - .then(done, done.fail); - }); - - it('preserves treemap level changes', function(done) { - function assertLevel(msg, exp) { - expect(gd._fullData[0].level).toBe(exp, msg); - } - - Plotly.react(gd, [{ - type: 'treemap', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'], - uirevision: 1 - }]) - .then(function() { - assertLevel('no set level at start', undefined); - }) - .then(function() { - var nodeSeth = d3Select('.slice:nth-child(2)').node(); - mouseEvent('click', 0, 0, {element: nodeSeth}); - }) - .then(function() { - assertLevel('after clicking on Seth sector', 'Seth'); - }) - .then(function() { - return Plotly.react(gd, [{ - type: 'treemap', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'], - uirevision: 1 - }]); - }) - .then(function() { - assertLevel('after reacting with new data, but with same uirevision', 'Seth'); - }) - .then(done, done.fail); - }); - - it('preserves icicle level changes', function(done) { - function assertLevel(msg, exp) { - expect(gd._fullData[0].level).toBe(exp, msg); - } + ['sunburst', 'icicle', 'treemap'].forEach(function(type) { + it('preserves ' + type + ' level changes', function(done) { + function assertLevel(msg, exp) { + expect(gd._fullData[0].level).toBe(exp, msg); + } - Plotly.react(gd, [{ - type: 'icicle', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'], - uirevision: 1 - }]) - .then(function() { - assertLevel('no set level at start', undefined); - }) - .then(function() { - var nodeSeth = d3Select('.slice:nth-child(2)').node(); - mouseEvent('click', 0, 0, {element: nodeSeth}); - }) - .then(function() { - assertLevel('after clicking on Seth sector', 'Seth'); - }) - .then(function() { - return Plotly.react(gd, [{ - type: 'icicle', - labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'], - parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'], + Plotly.react(gd, [{ + type: type, + labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'], + parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'], uirevision: 1 - }]); - }) - .then(function() { - assertLevel('after reacting with new data, but with same uirevision', 'Seth'); - }) - .then(done, done.fail); + }]) + .then(function() { + assertLevel('no set level at start', undefined); + }) + .then(function() { + var nodeSeth = d3Select('.slice:nth-child(2)').node(); + mouseEvent('click', 0, 0, {element: nodeSeth}); + }) + .then(function() { + assertLevel('after clicking on Seth sector', 'Seth'); + }) + .then(function() { + return Plotly.react(gd, [{ + type: type, + labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'], + parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'], + uirevision: 1 + }]); + }) + .then(function() { + assertLevel('after reacting with new data, but with same uirevision', 'Seth'); + }) + .then(done, done.fail); + }); }); });