@@ -6,6 +6,7 @@ var interactConstants = require('@src/constants/interactions');
6
6
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
7
7
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
8
8
var mouseEvent = require ( '../assets/mouse_event' ) ;
9
+ var Plots = require ( '@src/plots/plots' ) ;
9
10
10
11
describe ( 'editable titles' , function ( ) {
11
12
'use strict' ;
@@ -45,6 +46,24 @@ describe('editable titles', function() {
45
46
return promise ;
46
47
}
47
48
49
+ function editTitle ( letter , attr , text ) {
50
+ return new Promise ( function ( resolve ) {
51
+ gd . once ( 'plotly_relayout' , function ( eventData ) {
52
+ expect ( eventData [ attr ] ) . toEqual ( text , [ letter , attr , eventData ] ) ;
53
+ setTimeout ( resolve , 10 ) ;
54
+ } ) ;
55
+
56
+ var textNode = document . querySelector ( '.' + letter + 'title' ) ;
57
+ textNode . dispatchEvent ( new window . MouseEvent ( 'click' ) ) ;
58
+
59
+ var editNode = document . querySelector ( '.plugin-editable.editable' ) ;
60
+ editNode . dispatchEvent ( new window . FocusEvent ( 'focus' ) ) ;
61
+ editNode . textContent = text ;
62
+ editNode . dispatchEvent ( new window . FocusEvent ( 'focus' ) ) ;
63
+ editNode . dispatchEvent ( new window . FocusEvent ( 'blur' ) ) ;
64
+ } ) ;
65
+ }
66
+
48
67
it ( 'shows default titles semi-opaque with no hover effects' , function ( done ) {
49
68
Plotly . plot ( gd , data , { } , { editable : true } )
50
69
. then ( function ( ) {
@@ -84,11 +103,13 @@ describe('editable titles', function() {
84
103
title : ''
85
104
} , { editable : true } )
86
105
. then ( function ( ) {
87
- return Plotly . relayout ( gd , {
88
- 'xaxis.title' : 'XXX' ,
89
- 'yaxis.title' : 'YYY' ,
90
- 'title' : 'TTT'
91
- } ) ;
106
+ return editTitle ( 'x' , 'xaxis.title' , 'XXX' ) ;
107
+ } )
108
+ . then ( function ( ) {
109
+ return editTitle ( 'y' , 'yaxis.title' , 'YYY' ) ;
110
+ } )
111
+ . then ( function ( ) {
112
+ return editTitle ( 'g' , 'title' , 'TTT' ) ;
92
113
} )
93
114
. then ( function ( ) {
94
115
return Promise . all ( [
0 commit comments