@@ -9,6 +9,13 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
99describe ( 'Test plot structure' , function ( ) {
1010 'use strict' ;
1111
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+
1219 afterEach ( destroyGraphDiv ) ;
1320
1421 describe ( 'cartesian plots' , function ( ) {
@@ -21,17 +28,17 @@ describe('Test plot structure', function() {
2128
2229 it ( 'has one *subplot xy* node' , function ( ) {
2330 var nodes = d3 . selectAll ( 'g.subplot.xy' ) ;
24- expect ( nodes [ 0 ] . length ) . toEqual ( 1 ) ;
31+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
2532 } ) ;
2633
2734 it ( 'has one *scatterlayer* node' , function ( ) {
2835 var nodes = d3 . selectAll ( 'g.scatterlayer' ) ;
29- expect ( nodes [ 0 ] . length ) . toEqual ( 1 ) ;
36+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
3037 } ) ;
3138
3239 it ( 'has as many *trace scatter* nodes as there are traces' , function ( ) {
3340 var nodes = d3 . selectAll ( 'g.trace.scatter' ) ;
34- expect ( nodes [ 0 ] . length ) . toEqual ( mock . data . length ) ;
41+ expect ( nodes . size ( ) ) . toEqual ( mock . data . length ) ;
3542 } ) ;
3643
3744 it ( 'has as many *point* nodes as there are traces' , function ( ) {
@@ -42,7 +49,16 @@ describe('Test plot structure', function() {
4249 Npts += trace . x . length ;
4350 } ) ;
4451
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+ } ) ;
4662 } ) ;
4763 } ) ;
4864
@@ -61,7 +77,19 @@ describe('Test plot structure', function() {
6177 Npts += trace . values . length ;
6278 } ) ;
6379
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 ( ) ) ;
6593 } ) ;
6694 } ) ;
6795 } ) ;
@@ -82,7 +110,7 @@ describe('Test plot structure', function() {
82110 if ( items ) Npts += items . length ;
83111 } ) ;
84112
85- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
113+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
86114 } ) ;
87115
88116 it ( 'has as many *point* nodes as there are marker points' , function ( ) {
@@ -94,7 +122,23 @@ describe('Test plot structure', function() {
94122 if ( items ) Npts += items . length ;
95123 } ) ;
96124
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+ } ) ;
98142 } ) ;
99143 } ) ;
100144
@@ -113,7 +157,7 @@ describe('Test plot structure', function() {
113157 Npts += trace . r . length ;
114158 } ) ;
115159
116- expect ( nodes [ 0 ] . length ) . toEqual ( Npts ) ;
160+ expect ( nodes . size ( ) ) . toEqual ( Npts ) ;
117161 } ) ;
118162 } ) ;
119163} ) ;
0 commit comments