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

Skip to content

Commit 690b9f7

Browse files
committed
delay resolve() instead of manually clearing edit div
in finance legend item edit test case.
1 parent c66753b commit 690b9f7

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/jasmine/tests/finance_test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,9 @@ describe('finance charts *special* handlers:', function() {
968968

969969
afterEach(destroyGraphDiv);
970970

971-
it('`editable: true` handles should work', function(done) {
971+
it('`editable: true` handlers should work', function(done) {
972+
973+
var gd = createGraphDiv();
972974

973975
function editText(itemNumber, newText) {
974976
var textNode = d3.selectAll('text.legendtext')
@@ -981,11 +983,17 @@ describe('finance charts *special* handlers:', function() {
981983
editNode.textContent = newText;
982984
editNode.dispatchEvent(new window.FocusEvent('focus'));
983985
editNode.dispatchEvent(new window.FocusEvent('blur'));
986+
}
984987

985-
editNode.remove();
988+
// makeEditable in svg_text_utils clears the edit <div> in
989+
// a 0-second transition, so push the resolve call at the back
990+
// of the rendering queue to make sure the edit <div> is properly
991+
// cleared after each mocked text edits.
992+
function delayedResolve(resolve) {
993+
setTimeout(function() { return resolve(gd); }, 0);
986994
}
987995

988-
Plotly.plot(createGraphDiv(), [
996+
Plotly.plot(gd, [
989997
Lib.extendDeep({}, mock0, { type: 'ohlc' }),
990998
Lib.extendDeep({}, mock0, { type: 'candlestick' })
991999
], {}, {
@@ -996,7 +1004,7 @@ describe('finance charts *special* handlers:', function() {
9961004
gd.once('plotly_restyle', function(eventData) {
9971005
expect(eventData[0]['increasing.name']).toEqual('0');
9981006
expect(eventData[1]).toEqual([0]);
999-
resolve(gd);
1007+
delayedResolve(resolve);
10001008
});
10011009

10021010
editText(0, '0');
@@ -1007,7 +1015,7 @@ describe('finance charts *special* handlers:', function() {
10071015
gd.once('plotly_restyle', function(eventData) {
10081016
expect(eventData[0]['decreasing.name']).toEqual('1');
10091017
expect(eventData[1]).toEqual([0]);
1010-
resolve(gd);
1018+
delayedResolve(resolve);
10111019
});
10121020

10131021
editText(1, '1');
@@ -1018,7 +1026,7 @@ describe('finance charts *special* handlers:', function() {
10181026
gd.once('plotly_restyle', function(eventData) {
10191027
expect(eventData[0]['decreasing.name']).toEqual('2');
10201028
expect(eventData[1]).toEqual([1]);
1021-
resolve(gd);
1029+
delayedResolve(resolve);
10221030
});
10231031

10241032
editText(3, '2');
@@ -1029,7 +1037,7 @@ describe('finance charts *special* handlers:', function() {
10291037
gd.once('plotly_restyle', function(eventData) {
10301038
expect(eventData[0]['increasing.name']).toEqual('3');
10311039
expect(eventData[1]).toEqual([1]);
1032-
resolve(gd);
1040+
delayedResolve(resolve);
10331041
});
10341042

10351043
editText(2, '3');

0 commit comments

Comments
 (0)