@@ -25,7 +25,7 @@ describe('css injection', function() {
25
25
26
26
// the most basic of basic plots
27
27
function plot ( target ) {
28
- Plotly . plot ( target , [ {
28
+ return Plotly . plot ( target , [ {
29
29
x : [ 1 , 2 , 3 , 4 , 5 ] ,
30
30
y : [ 1 , 2 , 4 , 8 , 16 ]
31
31
} ] , {
@@ -60,7 +60,7 @@ describe('css injection', function() {
60
60
}
61
61
}
62
62
63
- it ( 'inserts styles on initial plot' , function ( ) {
63
+ it ( 'inserts styles on initial plot' , function ( done ) {
64
64
deletePlotCSSRules ( document ) ; // clear the rules
65
65
66
66
// fix scope errors
@@ -78,42 +78,44 @@ describe('css injection', function() {
78
78
79
79
// plot
80
80
var gd = createGraphDiv ( ) ;
81
- plot ( gd ) ;
81
+ plot ( gd ) . then ( function ( ) {
82
82
83
- // check for styles
84
- allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
83
+ // check for styles
84
+ allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
85
85
86
- for ( selector in plotcss ) {
87
- fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
86
+ for ( selector in plotcss ) {
87
+ fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
88
88
89
- expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
90
- }
89
+ expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
90
+ }
91
91
92
- // clean up
93
- destroyGraphDiv ( ) ;
92
+ // clean up
93
+ return destroyGraphDiv ( ) ;
94
+ } ) . then ( done ) ;
94
95
} ) ;
95
96
96
- it ( 'inserts styles in a child window document' , function ( ) {
97
+ it ( 'inserts styles in a child window document' , function ( done ) {
97
98
var gd = createGraphDivInChildWindow ( ) ;
98
99
var childWindow = gd . ownerDocument . defaultView ;
99
100
100
101
// plot
101
- plot ( gd ) ;
102
+ plot ( gd ) . then ( function ( ) {
102
103
103
- // check for styles
104
- var allSelectors = plotcss_utils . getAllRuleSelectors ( gd . ownerDocument ) ;
104
+ // check for styles
105
+ var allSelectors = plotcss_utils . getAllRuleSelectors ( gd . ownerDocument ) ;
105
106
106
- for ( var selector in plotcss ) {
107
- var fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
107
+ for ( var selector in plotcss ) {
108
+ var fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
108
109
109
- expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
110
- }
110
+ expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
111
+ }
111
112
112
- // clean up
113
- childWindow . close ( ) ;
113
+ // clean up
114
+ childWindow . close ( ) ;
115
+ } ) . then ( done ) ;
114
116
} ) ;
115
117
116
- it ( 'does not insert duplicate styles' , function ( ) {
118
+ it ( 'does not insert duplicate styles' , function ( done ) {
117
119
deletePlotCSSRules ( document ) ; // clear the rules
118
120
119
121
// fix scope errors
@@ -131,22 +133,23 @@ describe('css injection', function() {
131
133
132
134
// plot
133
135
var gd = createGraphDiv ( ) ;
134
- plot ( gd ) ;
135
- plot ( gd ) ; // plot again so injectStyles gets called again
136
-
137
- // check for styles
138
- allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
136
+ plot ( gd ) . then ( function ( ) {
137
+ return plot ( gd ) ; // plot again so injectStyles gets called again
138
+ } ) . then ( function ( ) {
139
+ // check for styles
140
+ allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
139
141
140
- for ( selector in plotcss ) {
141
- fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
142
+ for ( selector in plotcss ) {
143
+ fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
142
144
143
- var firstIndex = allSelectors . indexOf ( fullSelector ) ;
145
+ var firstIndex = allSelectors . indexOf ( fullSelector ) ;
144
146
145
- // there should be no occurences after the initial one
146
- expect ( allSelectors . indexOf ( fullSelector , firstIndex + 1 ) ) . toEqual ( - 1 ) ;
147
- }
147
+ // there should be no occurences after the initial one
148
+ expect ( allSelectors . indexOf ( fullSelector , firstIndex + 1 ) ) . toEqual ( - 1 ) ;
149
+ }
148
150
149
- // clean up
150
- destroyGraphDiv ( ) ;
151
+ // clean up
152
+ return destroyGraphDiv ( ) ;
153
+ } ) . then ( done ) ;
151
154
} ) ;
152
155
} ) ;
0 commit comments