@@ -31,14 +31,14 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
31
31
mock [ 0 ] . customdata = customdata ;
32
32
tests . push ( [ '%{customdata}' , customdata ] ) ;
33
33
34
- tests . forEach ( function ( test ) {
35
- it ( isGL ? '@gl' : '' + 'should support texttemplate' , function ( done ) {
36
- var gd = createGraphDiv ( ) ;
37
- var mockCopy = Lib . extendDeep ( mock , { } ) ;
38
- mockCopy [ 0 ] . texttemplate = test [ 0 ] ;
39
- Plotly . newPlot ( gd , mockCopy )
40
- . then ( function ( ) {
41
- if ( isGL ) {
34
+ if ( isGL ) {
35
+ tests . forEach ( function ( test ) {
36
+ it ( '@gl should support texttemplate' , function ( done ) {
37
+ var gd = createGraphDiv ( ) ;
38
+ var mockCopy = Lib . extendDeep ( mock , { } ) ;
39
+ mockCopy [ 0 ] . texttemplate = test [ 0 ] ;
40
+ Plotly . newPlot ( gd , mockCopy )
41
+ . then ( function ( ) {
42
42
var glText ;
43
43
if ( isPolar ) {
44
44
glText = gd . _fullLayout . polar . _subplot . _scene . glText ;
@@ -54,20 +54,36 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
54
54
var text = glText [ 0 ] . text . slice ( from , to ) ;
55
55
expect ( text ) . toEqual ( test [ 1 ] [ i ] ) ;
56
56
}
57
- } else {
57
+ } )
58
+ . catch ( failTest )
59
+ . finally ( function ( ) {
60
+ Plotly . purge ( gd ) ;
61
+ destroyGraphDiv ( ) ;
62
+ } )
63
+ . then ( done ) ;
64
+ } ) ;
65
+ } ) ;
66
+ } else {
67
+ tests . forEach ( function ( test ) {
68
+ it ( 'should support texttemplate' , function ( done ) {
69
+ var gd = createGraphDiv ( ) ;
70
+ var mockCopy = Lib . extendDeep ( mock , { } ) ;
71
+ mockCopy [ 0 ] . texttemplate = test [ 0 ] ;
72
+ Plotly . newPlot ( gd , mockCopy )
73
+ . then ( function ( ) {
58
74
var pts = Plotly . d3 . selectAll ( selector ) ;
59
75
expect ( pts . size ( ) ) . toBe ( test [ 1 ] . length ) ;
60
76
pts . each ( function ( ) {
61
77
expect ( test [ 1 ] ) . toContain ( Plotly . d3 . select ( this ) . text ( ) ) ;
62
78
} ) ;
63
- }
64
- } )
65
- . catch ( failTest )
66
- . finally ( function ( ) {
67
- Plotly . purge ( gd ) ;
68
- destroyGraphDiv ( ) ;
69
- } )
70
- . then ( done ) ;
79
+ } )
80
+ . catch ( failTest )
81
+ . finally ( function ( ) {
82
+ Plotly . purge ( gd ) ;
83
+ destroyGraphDiv ( ) ;
84
+ } )
85
+ . then ( done ) ;
86
+ } ) ;
71
87
} ) ;
72
- } ) ;
88
+ }
73
89
} ;
0 commit comments