@@ -187,7 +187,6 @@ describe('Pie traces:', function() {
187187 Plotly . newPlot ( gd , [ {
188188 values : [ 2 , 2 , 2 , 2 ] ,
189189 title : 'Test<br>Title' ,
190- titleposition : 'middle center' ,
191190 hole : 0.5 ,
192191 type : 'pie' ,
193192 textinfo : 'none'
@@ -243,22 +242,24 @@ describe('Pie traces:', function() {
243242 } ) ;
244243
245244 function _verifyTitle ( checkLeft , checkRight , checkTop , checkBottom , checkMiddleX ) {
246- var title = d3 . selectAll ( '.titletext text' ) ;
247- expect ( title . size ( ) ) . toBe ( 1 ) ;
248- var titleBox = d3 . select ( 'g.titletext' ) . node ( ) . getBoundingClientRect ( ) ;
249- var pieBox = d3 . select ( 'g.trace' ) . node ( ) . getBoundingClientRect ( ) ;
250- // check that margins agree. we leave an error margin of 2.
251- if ( checkLeft ) expect ( Math . abs ( titleBox . left - pieBox . left ) ) . toBeLessThan ( 2 ) ;
252- if ( checkRight ) expect ( Math . abs ( titleBox . right - pieBox . right ) ) . toBeLessThan ( 2 ) ;
253- if ( checkTop ) expect ( Math . abs ( titleBox . top - pieBox . top ) ) . toBeLessThan ( 2 ) ;
254- if ( checkBottom ) expect ( Math . abs ( titleBox . bottom - pieBox . bottom ) ) . toBeLessThan ( 2 ) ;
255- if ( checkMiddleX ) {
256- expect ( Math . abs ( titleBox . left + titleBox . right - pieBox . left - pieBox . right ) )
257- . toBeLessThan ( 2 ) ;
258- }
245+ return function ( ) {
246+ var title = d3 . selectAll ( '.titletext text' ) ;
247+ expect ( title . size ( ) ) . toBe ( 1 ) ;
248+ var titleBox = d3 . select ( 'g.titletext' ) . node ( ) . getBoundingClientRect ( ) ;
249+ var pieBox = d3 . select ( 'g.trace' ) . node ( ) . getBoundingClientRect ( ) ;
250+ // check that margins agree. we leave an error margin of 2.
251+ if ( checkLeft ) expect ( Math . abs ( titleBox . left - pieBox . left ) ) . toBeLessThan ( 2 ) ;
252+ if ( checkRight ) expect ( Math . abs ( titleBox . right - pieBox . right ) ) . toBeLessThan ( 2 ) ;
253+ if ( checkTop ) expect ( Math . abs ( titleBox . top - pieBox . top ) ) . toBeLessThan ( 2 ) ;
254+ if ( checkBottom ) expect ( Math . abs ( titleBox . bottom - pieBox . bottom ) ) . toBeLessThan ( 2 ) ;
255+ if ( checkMiddleX ) {
256+ expect ( Math . abs ( titleBox . left + titleBox . right - pieBox . left - pieBox . right ) )
257+ . toBeLessThan ( 2 ) ;
258+ }
259+ } ;
259260 }
260261
261- it ( 'shows title top center if there is no hole ' , function ( done ) {
262+ it ( 'shows title top center if hole is zero ' , function ( done ) {
262263 Plotly . newPlot ( gd , [ {
263264 values : [ 2 , 2 , 2 , 2 ] ,
264265 title : 'Test<BR>Title' ,
@@ -275,6 +276,21 @@ describe('Pie traces:', function() {
275276 . then ( done ) ;
276277 } ) ;
277278
279+ it ( 'shows title top center if titleposition is undefined and no hole' , function ( done ) {
280+ Plotly . newPlot ( gd , [ {
281+ values : [ 2 , 2 , 2 , 2 ] ,
282+ title : 'Test<BR>Title' ,
283+ titlefont : {
284+ size : 12
285+ } ,
286+ type : 'pie' ,
287+ textinfo : 'none'
288+ } ] , { height : 300 , width : 300 } )
289+ . then ( _verifyTitle ( false , false , true , false , true ) )
290+ . catch ( failTest )
291+ . then ( done ) ;
292+ } ) ;
293+
278294 it ( 'shows title top center' , function ( done ) {
279295 Plotly . newPlot ( gd , [ {
280296 values : [ 1 , 1 , 1 , 1 , 2 ] ,
0 commit comments