@@ -25,7 +25,7 @@ describe('css injection', function() {
2525
2626 // the most basic of basic plots
2727 function plot ( target ) {
28- Plotly . plot ( target , [ {
28+ return Plotly . plot ( target , [ {
2929 x : [ 1 , 2 , 3 , 4 , 5 ] ,
3030 y : [ 1 , 2 , 4 , 8 , 16 ]
3131 } ] , {
@@ -60,7 +60,7 @@ describe('css injection', function() {
6060 }
6161 }
6262
63- it ( 'inserts styles on initial plot' , function ( ) {
63+ it ( 'inserts styles on initial plot' , function ( done ) {
6464 deletePlotCSSRules ( document ) ; // clear the rules
6565
6666 // fix scope errors
@@ -78,42 +78,44 @@ describe('css injection', function() {
7878
7979 // plot
8080 var gd = createGraphDiv ( ) ;
81- plot ( gd ) ;
81+ plot ( gd ) . then ( function ( ) {
8282
83- // check for styles
84- allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
83+ // check for styles
84+ allSelectors = plotcss_utils . getAllRuleSelectors ( document ) ;
8585
86- for ( selector in plotcss ) {
87- fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
86+ for ( selector in plotcss ) {
87+ fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
8888
89- expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
90- }
89+ expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
90+ }
9191
92- // clean up
93- destroyGraphDiv ( ) ;
92+ // clean up
93+ return destroyGraphDiv ( ) ;
94+ } ) . then ( done ) ;
9495 } ) ;
9596
96- it ( 'inserts styles in a child window document' , function ( ) {
97+ it ( 'inserts styles in a child window document' , function ( done ) {
9798 var gd = createGraphDivInChildWindow ( ) ;
9899 var childWindow = gd . ownerDocument . defaultView ;
99100
100101 // plot
101- plot ( gd ) ;
102+ plot ( gd ) . then ( function ( ) {
102103
103- // check for styles
104- var allSelectors = plotcss_utils . getAllRuleSelectors ( gd . ownerDocument ) ;
104+ // check for styles
105+ var allSelectors = plotcss_utils . getAllRuleSelectors ( gd . ownerDocument ) ;
105106
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 ) ;
108109
109- expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
110- }
110+ expect ( allSelectors . indexOf ( fullSelector ) ) . not . toEqual ( - 1 ) ;
111+ }
111112
112- // clean up
113- childWindow . close ( ) ;
113+ // clean up
114+ childWindow . close ( ) ;
115+ } ) . then ( done ) ;
114116 } ) ;
115117
116- it ( 'does not insert duplicate styles' , function ( ) {
118+ it ( 'does not insert duplicate styles' , function ( done ) {
117119 deletePlotCSSRules ( document ) ; // clear the rules
118120
119121 // fix scope errors
@@ -131,22 +133,23 @@ describe('css injection', function() {
131133
132134 // plot
133135 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 ) ;
139141
140- for ( selector in plotcss ) {
141- fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
142+ for ( selector in plotcss ) {
143+ fullSelector = plotcss_utils . buildFullSelector ( selector ) ;
142144
143- var firstIndex = allSelectors . indexOf ( fullSelector ) ;
145+ var firstIndex = allSelectors . indexOf ( fullSelector ) ;
144146
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+ }
148150
149- // clean up
150- destroyGraphDiv ( ) ;
151+ // clean up
152+ return destroyGraphDiv ( ) ;
153+ } ) . then ( done ) ;
151154 } ) ;
152155} ) ;
0 commit comments