@@ -12,16 +12,39 @@ var supplyAllDefaults = require('../assets/supply_defaults');
12
12
module . exports = function checkTextTemplate ( mock , selector , tests ) {
13
13
var isGL = Registry . traceIs ( mock [ 0 ] . type , 'gl' ) ;
14
14
var isPolar = Registry . traceIs ( mock [ 0 ] . type , 'polar' ) ;
15
+ var isScatterLike = Registry . traceIs ( mock [ 0 ] . type , 'scatter-like' ) ;
16
+ var isBarLike = Registry . traceIs ( mock [ 0 ] . type , 'bar-like' ) ;
15
17
16
- it ( 'should not coerce textinfo when texttemplate' , function ( ) {
18
+ it ( 'should not coerce textinfo when texttemplate is defined ' , function ( ) {
17
19
var gd = { } ;
18
- gd . data = Lib . extendDeep ( mock , { } ) ;
20
+ gd . data = Lib . extendDeep ( [ ] , mock ) ;
19
21
gd . data [ 0 ] . textinfo = 'text' ;
20
- gd . data [ 0 ] . texttemplate = tests [ 0 ] [ 0 ] ;
22
+ gd . data [ 0 ] . texttemplate = 'texttemplate' ;
21
23
supplyAllDefaults ( gd ) ;
22
24
expect ( gd . _fullData [ 0 ] . textinfo ) . toBe ( undefined ) ;
23
25
} ) ;
24
26
27
+ if ( isScatterLike ) {
28
+ it ( 'should not coerce texttemplate when mode has no `text` flag' , function ( ) {
29
+ var gd = { } ;
30
+ gd . data = Lib . extendDeep ( [ ] , mock ) ;
31
+ gd . data [ 0 ] . mode = 'markers' ;
32
+ gd . data [ 0 ] . texttemplate = 'texttemplate' ;
33
+ supplyAllDefaults ( gd ) ;
34
+ expect ( gd . _fullData [ 0 ] . texttemplate ) . toBe ( undefined ) ;
35
+ } ) ;
36
+ }
37
+
38
+ if ( isBarLike ) {
39
+ it ( 'should not coerce texttemplate when textposition is `none`' , function ( ) {
40
+ var gd = { } ;
41
+ gd . data = Lib . extendDeep ( [ ] , mock ) ;
42
+ gd . data [ 0 ] . textposition = 'none' ;
43
+ gd . data [ 0 ] . texttemplate = 'texttemplate' ;
44
+ supplyAllDefaults ( gd ) ;
45
+ expect ( gd . _fullData [ 0 ] . texttemplate ) . toBe ( undefined ) ;
46
+ } ) ;
47
+ }
25
48
26
49
var N = tests [ 0 ] [ 1 ] . length ;
27
50
var i ;
@@ -46,7 +69,7 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
46
69
tests . forEach ( function ( test ) {
47
70
it ( '@gl should support texttemplate' , function ( done ) {
48
71
var gd = createGraphDiv ( ) ;
49
- var mockCopy = Lib . extendDeep ( mock , { } ) ;
72
+ var mockCopy = Lib . extendDeep ( [ ] , mock ) ;
50
73
mockCopy [ 0 ] . texttemplate = test [ 0 ] ;
51
74
Plotly . newPlot ( gd , mockCopy )
52
75
. then ( function ( ) {
@@ -78,7 +101,7 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
78
101
tests . forEach ( function ( test ) {
79
102
it ( 'should support texttemplate' , function ( done ) {
80
103
var gd = createGraphDiv ( ) ;
81
- var mockCopy = Lib . extendDeep ( mock , { } ) ;
104
+ var mockCopy = Lib . extendDeep ( [ ] , mock ) ;
82
105
mockCopy [ 0 ] . texttemplate = test [ 0 ] ;
83
106
Plotly . newPlot ( gd , mockCopy )
84
107
. then ( function ( ) {
0 commit comments