@@ -22,17 +22,22 @@ diffTest('6a', '6b', '6diff', options, 51);
2222diffTest ( '6a' , '6a' , '6empty' , { threshold : 0 } , 0 ) ;
2323
2424test ( 'throws error if image sizes do not match' , ( t ) => {
25- t . throws ( ( ) => match ( [ 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , null , 2 , 1 ) , / I m a g e s i z e s d o n o t m a t c h / ) ;
25+ t . throws ( ( ) => match ( new Uint8Array ( 8 ) , new Uint8Array ( 9 ) , null , 2 , 1 ) , 'Image sizes do not match' ) ;
26+ t . end ( ) ;
27+ } ) ;
28+
29+ test ( 'throws error if image sizes do not match width and height' , ( t ) => {
30+ t . throws ( ( ) => match ( new Uint8Array ( 9 ) , new Uint8Array ( 9 ) , null , 2 , 1 ) , 'Image data size does not match width/height' ) ;
2631 t . end ( ) ;
2732} ) ;
2833
2934test ( 'throws error if provided wrong image data format' , ( t ) => {
30- const re = / I m a g e d a t a : U i n t 8 A r r a y , U i n t 8 C l a m p e d A r r a y o r B u f f e r e x p e c t e d / ;
35+ const err = ' Image data: Uint8Array, Uint8ClampedArray or Buffer expected' ;
3136 const arr = new Uint8Array ( 4 * 20 * 20 ) ;
3237 const bad = new Array ( arr . length ) . fill ( 0 ) ;
33- t . throws ( ( ) => match ( bad , arr , null , 20 , 20 ) , re ) ;
34- t . throws ( ( ) => match ( arr , bad , null , 20 , 20 ) , re ) ;
35- t . throws ( ( ) => match ( arr , arr , bad , 20 , 20 ) , re ) ;
38+ t . throws ( ( ) => match ( bad , arr , null , 20 , 20 ) , err ) ;
39+ t . throws ( ( ) => match ( arr , bad , null , 20 , 20 ) , err ) ;
40+ t . throws ( ( ) => match ( arr , arr , bad , 20 , 20 ) , err ) ;
3641 t . end ( ) ;
3742} ) ;
3843
@@ -52,10 +57,10 @@ function diffTest(imgPath1, imgPath2, diffPath, options, expectedMismatch) {
5257 writeImage ( diffPath , diff ) ;
5358 } else {
5459 const expectedDiff = readImage ( diffPath ) ;
55- t . same ( diff . data , expectedDiff . data , 'diff image' ) ;
60+ t . ok ( diff . data . equals ( expectedDiff . data ) , 'diff image' ) ;
5661 }
57- t . same ( mismatch , expectedMismatch , 'number of mismatched pixels' ) ;
58- t . same ( mismatch , mismatch2 , 'number of mismatched pixels without diff' ) ;
62+ t . equal ( mismatch , expectedMismatch , 'number of mismatched pixels' ) ;
63+ t . equal ( mismatch , mismatch2 , 'number of mismatched pixels without diff' ) ;
5964
6065 t . end ( ) ;
6166 } ) ;
0 commit comments