File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ describe('Test Plots', function() {
88 'use strict' ;
99
1010 describe ( 'Plotly.supplyDefaults' , function ( ) {
11+ function testSanitizeMarginsHasBeenCalledOnlyOnce ( gd ) {
12+ spyOn ( Plots , 'sanitizeMargins' ) . and . callThrough ( ) ;
13+ Plots . supplyDefaults ( gd ) ;
14+ expect ( Plots . sanitizeMargins ) . toHaveBeenCalledTimes ( 1 ) ;
15+ }
16+
1117 it ( 'should not throw an error when gd is a plain object' , function ( ) {
1218 var height = 100 ,
1319 gd = {
@@ -23,6 +29,39 @@ describe('Test Plots', function() {
2329 expect ( gd . _fullLayout . width ) . toBe ( Plots . layoutAttributes . width . dflt ) ;
2430 expect ( gd . _fullData ) . toBeDefined ( ) ;
2531 } ) ;
32+
33+ it ( 'should call sanitizeMargins only once when both width and height are defined' , function ( ) {
34+ var gd = {
35+ layout : {
36+ width : 100 ,
37+ height : 100
38+ }
39+ } ;
40+
41+ testSanitizeMarginsHasBeenCalledOnlyOnce ( gd ) ;
42+ } ) ;
43+
44+ it ( 'should call sanitizeMargins only once when autosize is false' , function ( ) {
45+ var gd = {
46+ layout : {
47+ autosize : false ,
48+ height : 100
49+ }
50+ } ;
51+
52+ testSanitizeMarginsHasBeenCalledOnlyOnce ( gd ) ;
53+ } ) ;
54+
55+ it ( 'should call sanitizeMargins only once when autosize is true' , function ( ) {
56+ var gd = {
57+ layout : {
58+ autosize : true ,
59+ height : 100
60+ }
61+ } ;
62+
63+ testSanitizeMarginsHasBeenCalledOnlyOnce ( gd ) ;
64+ } ) ;
2665 } ) ;
2766
2867 describe ( 'Plots.supplyLayoutGlobalDefaults should' , function ( ) {
You can’t perform that action at this time.
0 commit comments