@@ -11,6 +11,7 @@ var failTest = require('../assets/fail_test');
1111
1212var customAssertions = require ( '../assets/custom_assertions' ) ;
1313var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
14+ var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
1415var Fx = require ( '@src/components/fx' ) ;
1516
1617describe ( 'image supplyDefaults' , function ( ) {
@@ -108,51 +109,39 @@ describe('image smart layout defaults', function() {
108109
109110 afterEach ( destroyGraphDiv ) ;
110111
111- it ( 'should reverse yaxis if only images are present' , function ( done ) {
112- Plotly . newPlot ( gd , [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } ] )
113- . then ( function ( gd ) {
114- expect ( gd . _fullLayout . yaxis . range [ 0 ] ) . toBeGreaterThan ( gd . _fullLayout . yaxis . range [ 1 ] ) ;
115- } )
116- . catch ( failTest )
117- . then ( done ) ;
112+ it ( 'should reverse yaxis if only images are present' , function ( ) {
113+ gd = { } ;
114+ gd . data = [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } ] ;
115+ supplyAllDefaults ( gd ) ;
116+ expect ( gd . _fullLayout . yaxis . autorange ) . toBe ( 'reversed' ) ;
118117 } ) ;
119118
120- it ( 'should NOT reverse yaxis if another trace is present' , function ( done ) {
121- Plotly . newPlot ( gd , [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] } ] )
122- . then ( function ( gd ) {
123- expect ( gd . _fullLayout . yaxis . range [ 1 ] ) . toBeGreaterThan ( gd . _fullLayout . yaxis . range [ 0 ] ) ;
124- } )
125- . catch ( failTest )
126- . then ( done ) ;
119+ it ( 'should NOT reverse yaxis if another trace is present' , function ( ) {
120+ gd = { } ;
121+ gd . data = [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] } ] ;
122+ supplyAllDefaults ( gd ) ;
123+ expect ( gd . _fullLayout . yaxis . autorange ) . not . toBe ( 'reversed' ) ;
127124 } ) ;
128125
129- it ( 'should set scaleanchor to make square pixels if only images are present' , function ( done ) {
130- Plotly . newPlot ( gd , [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } ] )
131- . then ( function ( gd ) {
132- expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( 'x' ) ;
133- } )
134- . catch ( failTest )
135- . then ( done ) ;
126+ it ( 'should set scaleanchor to make square pixels if only images are present' , function ( ) {
127+ gd = { } ;
128+ gd . data = [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } ] ;
129+ supplyAllDefaults ( gd ) ;
130+ expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( 'x' ) ;
136131 } ) ;
137132
138- it ( 'should NOT set scaleanchor if another trace is present' , function ( done ) {
139- Plotly . newPlot ( gd , [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] } ] )
140- . then ( function ( gd ) {
141- expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( undefined ) ;
142- } )
143- . catch ( failTest )
144- . then ( done ) ;
133+ it ( 'should NOT set scaleanchor if another trace is present' , function ( ) {
134+ gd = { } ;
135+ gd . data = [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] } ] ;
136+ supplyAllDefaults ( gd ) ;
137+ expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( undefined ) ;
145138 } ) ;
146139
147- it ( 'should NOT set scaleanchor if it\'s already defined' , function ( done ) {
148- Plotly . newPlot ( gd , [
149- { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] }
150- ] , { yaxis : { scaleanchor : 'x3' } } )
151- . then ( function ( gd ) {
152- expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( undefined ) ;
153- } )
154- . catch ( failTest )
155- . then ( done ) ;
140+ it ( 'should NOT set scaleanchor if it\'s already defined' , function ( ) {
141+ gd . data = [ { type : 'image' , z : [ [ [ 255 , 0 , 0 ] ] ] } , { type : 'scatter' , y : [ 5 , 3 , 2 ] } ] ;
142+ gd . layout = { yaxis : { scaleanchor : 'x3' } } ;
143+ supplyAllDefaults ( gd ) ;
144+ expect ( gd . _fullLayout . yaxis . scaleanchor ) . toBe ( undefined ) ;
156145 } ) ;
157146} ) ;
158147
0 commit comments