@@ -83,6 +83,15 @@ const rejects = async (name, fn, Type, pattern) => {
8383 await rejects ( 'resize mode' , ( ) => image . clone ( ) . resize ( 4 , 4 , { mode : 'lanczos' } ) , TypeError , / r e s i z e m o d e m u s t b e ' n e a r e s t - n e i g h b o r ' , ' b i l i n e a r ' , ' b i c u b i c ' o r ' a r e a ' , n o t ' l a n c z o s ' / ) ;
8484 await rejects ( 'scale mode' , ( ) => image . clone ( ) . scale ( 2 , { mode : 'lanczos' } ) , TypeError , / r e s i z e m o d e m u s t b e / ) ;
8585 await rejects ( 'blend mode' , ( ) => image . clone ( ) . composite ( image , { mode : 'nope' } ) , TypeError , / b l e n d m o d e m u s t b e / ) ;
86+
87+ // scale() doesn't shrink a side below one pixel, like resize({ width }) keeping the aspect ratio
88+ {
89+ const thin = new Image ( 7 , 1 ) . scale ( 0.5 ) ;
90+ if ( thin . width !== 3 || thin . height !== 1 ) panic ( `new Image(7, 1).scale(0.5) is ${ thin . width } x${ thin . height } ` ) ;
91+ const tiny = new Image ( 10 , 3 ) . scale ( 0.01 ) ;
92+ if ( tiny . width !== 1 || tiny . height !== 1 ) panic ( `scale(0.01) is ${ tiny . width } x${ tiny . height } ` ) ;
93+ for ( const factor of [ 0 , - 1 , NaN ] ) await rejects ( `scale(${ factor } )` , ( ) => image . clone ( ) . scale ( factor ) , RangeError , / ./ ) ;
94+ }
8695 await rejects ( 'flip direction' , ( ) => image . clone ( ) . flip ( 'diagonal' ) , TypeError , / f l i p d i r e c t i o n m u s t b e ' h o r i z o n t a l ' o r ' v e r t i c a l ' / ) ;
8796 await rejects ( 'disposal mode' , ( ) => new Frame ( image , { disposalMode : 'none' } ) , TypeError , / d i s p o s a l m o d e m u s t b e / ) ;
8897 await rejects ( 'wrapStyle' , ( ) => Image . renderText ( 'hi' , { font : new Uint8Array ( 4 ) , size : 8 , wrapStyle : 'line' } ) , TypeError , / w r a p S t y l e m u s t b e ' w o r d ' o r ' c h a r ' / ) ;
0 commit comments