@@ -5,6 +5,7 @@ var Colorbar = require('@src/components/colorbar');
55var createGraphDiv = require ( '../assets/create_graph_div' ) ;
66var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
77var failTest = require ( '../assets/fail_test' ) ;
8+ var assertPlotSize = require ( '../assets/custom_assertions' ) . assertPlotSize ;
89
910
1011describe ( 'Test colorbar:' , function ( ) {
@@ -127,11 +128,7 @@ describe('Test colorbar:', function() {
127128 var colorbars = d3 . select ( gd ) . selectAll ( '.colorbar' ) ;
128129 expect ( colorbars . size ( ) ) . toBe ( present ? 1 : 0 ) ;
129130
130- var yLines = d3 . select ( gd ) . selectAll ( '.ygrid' ) ;
131- expect ( yLines . size ( ) ) . toBeGreaterThan ( 0 ) ;
132- var yLineWidth = + yLines . node ( ) . getBoundingClientRect ( ) . width ;
133- if ( expandedMargin ) expect ( yLineWidth ) . toBeLessThan ( 400 ) ;
134- else expect ( yLineWidth ) . toBe ( 400 ) ;
131+ assertPlotSize ( expandedMargin ? { widthLessThan : 400 } : { width : 400 } ) ;
135132 }
136133
137134 Plotly . newPlot ( gd , [ {
@@ -170,11 +167,7 @@ describe('Test colorbar:', function() {
170167 var colorbars = d3 . select ( gd ) . selectAll ( '.colorbar' ) ;
171168 expect ( colorbars . size ( ) ) . toBe ( present ? 1 : 0 ) ;
172169
173- var yLines = d3 . select ( gd ) . selectAll ( '.ygrid' ) ;
174- expect ( yLines . size ( ) ) . toBeGreaterThan ( 0 ) ;
175- var yLineWidth = + yLines . node ( ) . getBoundingClientRect ( ) . width ;
176- if ( expandedMargin ) expect ( yLineWidth ) . toBeLessThan ( 400 ) ;
177- else expect ( yLineWidth ) . toBe ( 400 ) ;
170+ assertPlotSize ( expandedMargin ? { widthLessThan : 400 } : { width : 400 } ) ;
178171 }
179172
180173 Plotly . newPlot ( gd , [ {
0 commit comments