Skip to content

Commit c66753b

Browse files
committed
add editable: true legend item test case for finance traces
1 parent 01ecd3f commit c66753b

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

test/jasmine/tests/finance_test.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,79 @@ describe('finance charts updates:', function() {
963963
});
964964
});
965965
});
966+
967+
describe('finance charts *special* handlers:', function() {
968+
969+
afterEach(destroyGraphDiv);
970+
971+
it('`editable: true` handles should work', function(done) {
972+
973+
function editText(itemNumber, newText) {
974+
var textNode = d3.selectAll('text.legendtext')
975+
.filter(function(_, i) { return i === itemNumber; }).node();
976+
textNode.dispatchEvent(new window.MouseEvent('click'));
977+
978+
var editNode = d3.select('.plugin-editable.editable').node();
979+
editNode.dispatchEvent(new window.FocusEvent('focus'));
980+
981+
editNode.textContent = newText;
982+
editNode.dispatchEvent(new window.FocusEvent('focus'));
983+
editNode.dispatchEvent(new window.FocusEvent('blur'));
984+
985+
editNode.remove();
986+
}
987+
988+
Plotly.plot(createGraphDiv(), [
989+
Lib.extendDeep({}, mock0, { type: 'ohlc' }),
990+
Lib.extendDeep({}, mock0, { type: 'candlestick' })
991+
], {}, {
992+
editable: true
993+
})
994+
.then(function(gd) {
995+
return new Promise(function(resolve) {
996+
gd.once('plotly_restyle', function(eventData) {
997+
expect(eventData[0]['increasing.name']).toEqual('0');
998+
expect(eventData[1]).toEqual([0]);
999+
resolve(gd);
1000+
});
1001+
1002+
editText(0, '0');
1003+
});
1004+
})
1005+
.then(function(gd) {
1006+
return new Promise(function(resolve) {
1007+
gd.once('plotly_restyle', function(eventData) {
1008+
expect(eventData[0]['decreasing.name']).toEqual('1');
1009+
expect(eventData[1]).toEqual([0]);
1010+
resolve(gd);
1011+
});
1012+
1013+
editText(1, '1');
1014+
});
1015+
})
1016+
.then(function(gd) {
1017+
return new Promise(function(resolve) {
1018+
gd.once('plotly_restyle', function(eventData) {
1019+
expect(eventData[0]['decreasing.name']).toEqual('2');
1020+
expect(eventData[1]).toEqual([1]);
1021+
resolve(gd);
1022+
});
1023+
1024+
editText(3, '2');
1025+
});
1026+
})
1027+
.then(function(gd) {
1028+
return new Promise(function(resolve) {
1029+
gd.once('plotly_restyle', function(eventData) {
1030+
expect(eventData[0]['increasing.name']).toEqual('3');
1031+
expect(eventData[1]).toEqual([1]);
1032+
resolve(gd);
1033+
});
1034+
1035+
editText(2, '3');
1036+
});
1037+
})
1038+
.then(done);
1039+
});
1040+
1041+
});

0 commit comments

Comments
 (0)