@@ -65,6 +65,20 @@ describe('Plotly.downloadImage', function() {
6565 downloadTest ( 'graph' , 'svg' , done ) ;
6666 } , LONG_TIMEOUT_INTERVAL ) ;
6767
68+ it ( 'should work when passing a figure object' , function ( done ) {
69+ var fig = {
70+ data : [ { y : [ 1 , 2 , 1 ] } ]
71+ } ;
72+ Plotly . downloadImage ( fig )
73+ . then ( function ( ) {
74+ expect ( document . createElement ) . toHaveBeenCalledWith ( 'canvas' ) ;
75+ expect ( gd . _snapshotInProgress )
76+ . toBe ( undefined , 'should not attach _snapshotInProgress to figure objects' ) ;
77+ } )
78+ . catch ( failTest )
79+ . then ( done ) ;
80+ } , LONG_TIMEOUT_INTERVAL ) ;
81+
6882 it ( 'should produce the right SVG output in IE' , function ( done ) {
6983 // mock up IE behavior
7084 spyOn ( Lib , 'isIE' ) . and . callFake ( function ( ) { return true ; } ) ;
@@ -131,15 +145,24 @@ function downloadTest(gd, format, done) {
131145 } ) ;
132146 } ) ;
133147
134- Plotly . plot ( gd , textchartMock . data , textchartMock . layout ) . then ( function ( ) {
148+ Plotly . plot ( gd , textchartMock . data , textchartMock . layout ) . then ( function ( _gd ) {
135149 // start observing dom
136150 // configuration of the observer:
137151 var config = { childList : true } ;
138152
139153 // pass in the target node and observer options
140154 observer . observe ( target , config ) ;
141155
142- return Plotly . downloadImage ( gd , { format : format , height : 300 , width : 300 , filename : 'plotly_download' } ) ;
156+ var promise = Plotly . downloadImage ( gd , {
157+ format : format ,
158+ height : 300 ,
159+ width : 300 ,
160+ filename : 'plotly_download'
161+ } ) ;
162+
163+ expect ( _gd . _snapshotInProgress ) . toBe ( true , 'should attach _snapshotInProgress to graph divs' ) ;
164+
165+ return promise ;
143166 } )
144167 . then ( function ( filename ) {
145168 // stop observing
@@ -160,7 +183,6 @@ function downloadTest(gd, format, done) {
160183 . then ( done ) ;
161184}
162185
163-
164186// Only chrome supports webp at the time of writing
165187function checkWebp ( cb ) {
166188 var img = new Image ( ) ;
0 commit comments