File tree Expand file tree Collapse file tree 2 files changed +23
-15
lines changed Expand file tree Collapse file tree 2 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -297,22 +297,22 @@ Worker.prototype.set = function set(opt) {
297297
298298 // Build an array of setter functions to queue.
299299 var fns = Object . keys ( opt || { } ) . map ( function ( key ) {
300- if ( key in Worker . template . prop ) {
301- // Set pre-defined properties.
302- return function set_prop ( ) { this . prop [ key ] = opt [ key ] ; }
303- } else {
304- switch ( key ) {
305- case 'margin ' :
306- return this . setMargin . bind ( this , opt . margin ) ;
307- case 'jsPDF' :
308- return function set_jsPDF ( ) { this . opt . jsPDF = opt . jsPDF ; return this . setPageSize ( ) ; }
309- case 'pageSize' :
310- return this . setPageSize . bind ( this , opt . pageSize ) ;
311- default :
312- // Set any other properties in opt.
313- return function set_opt ( ) { this . opt [ key ] = opt [ key ] } ;
300+ switch ( key ) {
301+ case 'margin' :
302+ return this . setMargin . bind ( this , opt . margin ) ;
303+ case 'jsPDF' :
304+ return function set_jsPDF ( ) { this . opt . jsPDF = opt . jsPDF ; return this . setPageSize ( ) ; }
305+ case 'pageSize ' :
306+ return this . setPageSize . bind ( this , opt . pageSize ) ;
307+ default :
308+ if ( key in Worker . template . prop ) {
309+ // Set pre-defined properties in prop.
310+ return function set_prop ( ) { this . prop [ key ] = opt [ key ] ; }
311+ } else {
312+ // Set any other properties in opt.
313+ return function set_opt ( ) { this . opt [ key ] = opt [ key ] } ;
314314 }
315- }
315+ }
316316 } , this ) ;
317317
318318 // Set properties within the promise chain.
Original file line number Diff line number Diff line change @@ -92,6 +92,14 @@ describe('settings', function () {
9292 return Math . floor ( val * k / 72 * 96 ) ;
9393 }
9494
95+ it ( 'set({ pageSize }) should call setPageSize' , function ( ) {
96+ var worker = html2pdf ( ) ;
97+ chai . spy . on ( worker , 'setPageSize' , function ( ) { return this . then ( function ( ) { } ) ; } ) ;
98+ return worker . set ( { pageSize : 'test' } ) . then ( function ( ) {
99+ expect ( worker . setPageSize ) . to . have . been . called . with ( 'test' ) ;
100+ chai . spy . restore ( ) ;
101+ } ) ;
102+ } ) ;
95103 it ( 'setPageSize() with no argument should use jsPDF default settings' , function ( ) {
96104 var worker = html2pdf ( ) ;
97105 return worker . setPageSize ( ) . get ( 'pageSize' ) . then ( function ( val ) {
You can’t perform that action at this time.
0 commit comments