@@ -9,6 +9,13 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
9
9
describe ( 'Test plot structure' , function ( ) {
10
10
'use strict' ;
11
11
12
+ function assertNamespaces ( node ) {
13
+ expect ( node . getAttribute ( 'xmlns' ) )
14
+ . toEqual ( 'http://www.w3.org/2000/svg' ) ;
15
+ expect ( node . getAttribute ( 'xmlns:xlink' ) )
16
+ . toEqual ( 'http://www.w3.org/1999/xlink' ) ;
17
+ }
18
+
12
19
afterEach ( destroyGraphDiv ) ;
13
20
14
21
describe ( 'cartesian plots' , function ( ) {
@@ -21,17 +28,17 @@ describe('Test plot structure', function() {
21
28
22
29
it ( 'has one *subplot xy* node' , function ( ) {
23
30
var nodes = d3 . selectAll ( 'g.subplot.xy' ) ;
24
- expect ( nodes [ 0 ] . length ) . toEqual ( 1 ) ;
31
+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
25
32
} ) ;
26
33
27
34
it ( 'has one *scatterlayer* node' , function ( ) {
28
35
var nodes = d3 . selectAll ( 'g.scatterlayer' ) ;
29
- expect ( nodes [ 0 ] . length ) . toEqual ( 1 ) ;
36
+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
30
37
} ) ;
31
38
32
39
it ( 'has as many *trace scatter* nodes as there are traces' , function ( ) {
33
40
var nodes = d3 . selectAll ( 'g.trace.scatter' ) ;
34
- expect ( nodes [ 0 ] . length ) . toEqual ( mock . data . length ) ;
41
+ expect ( nodes . size ( ) ) . toEqual ( mock . data . length ) ;
35
42
} ) ;
36
43
37
44
it ( 'has as many *point* nodes as there are traces' , function ( ) {
@@ -42,7 +49,16 @@ describe('Test plot structure', function() {
42
49
Npts += trace . x . length ;
43
50
} ) ;
44
51
45
- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
52
+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
53
+ } ) ;
54
+
55
+ it ( 'has the correct name spaces' , function ( ) {
56
+ var mainSVGs = d3 . selectAll ( '.main-svg' ) ;
57
+
58
+ mainSVGs . each ( function ( ) {
59
+ var node = this ;
60
+ assertNamespaces ( node ) ;
61
+ } ) ;
46
62
} ) ;
47
63
} ) ;
48
64
@@ -61,7 +77,19 @@ describe('Test plot structure', function() {
61
77
Npts += trace . values . length ;
62
78
} ) ;
63
79
64
- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
80
+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
81
+ } ) ;
82
+
83
+ it ( 'has the correct name spaces' , function ( ) {
84
+ var mainSVGs = d3 . selectAll ( '.main-svg' ) ;
85
+
86
+ mainSVGs . each ( function ( ) {
87
+ var node = this ;
88
+ assertNamespaces ( node ) ;
89
+ } ) ;
90
+
91
+ var testerSVG = d3 . selectAll ( '#js-plotly-tester' ) ;
92
+ assertNamespaces ( testerSVG . node ( ) ) ;
65
93
} ) ;
66
94
} ) ;
67
95
} ) ;
@@ -82,7 +110,7 @@ describe('Test plot structure', function() {
82
110
if ( items ) Npts += items . length ;
83
111
} ) ;
84
112
85
- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
113
+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
86
114
} ) ;
87
115
88
116
it ( 'has as many *point* nodes as there are marker points' , function ( ) {
@@ -94,7 +122,23 @@ describe('Test plot structure', function() {
94
122
if ( items ) Npts += items . length ;
95
123
} ) ;
96
124
97
- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
125
+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
126
+ } ) ;
127
+
128
+ it ( 'has the correct name spaces' , function ( ) {
129
+ var mainSVGs = d3 . selectAll ( '.main-svg' ) ;
130
+
131
+ mainSVGs . each ( function ( ) {
132
+ var node = this ;
133
+ assertNamespaces ( node ) ;
134
+ } ) ;
135
+
136
+ var geoSVGs = d3 . select ( '#geo' ) . selectAll ( 'svg' ) ;
137
+
138
+ geoSVGs . each ( function ( ) {
139
+ var node = this ;
140
+ assertNamespaces ( node ) ;
141
+ } ) ;
98
142
} ) ;
99
143
} ) ;
100
144
@@ -113,7 +157,7 @@ describe('Test plot structure', function() {
113
157
Npts += trace . r . length ;
114
158
} ) ;
115
159
116
- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
160
+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
117
161
} ) ;
118
162
} ) ;
119
163
} ) ;
0 commit comments