@@ -35,6 +35,21 @@ const panic = msg => {
3535 if ( ! Buffer . from ( target ) . equals ( Buffer . from ( encoded ) ) ) panic ( 'rotate 45 noresize failed' ) ;
3636 }
3737
38+ {
39+ const binary = await fs . readFile ( './tests/targets/image.png' ) ;
40+ const image = await Image . decode ( binary ) ;
41+ image . rotate ( 90 ) ;
42+
43+ const encoded = await image . encode ( 1 , { creationTime : 0 , software : '' } ) ;
44+
45+ if ( process . env . OVERWRITE_TEST )
46+ await fs . writeFile ( './tests/targets/rotate-90.png' , encoded ) ;
47+
48+ await fs . writeFile ( './tests/targets/rotate-90.png' , encoded ) ;
49+ const target = await fs . readFile ( './tests/targets/rotate-90.png' ) ;
50+ if ( ! Buffer . from ( target ) . equals ( Buffer . from ( encoded ) ) ) panic ( 'rotate 90 failed' ) ;
51+ }
52+
3853 {
3954 const binary = await fs . readFile ( './tests/targets/image.png' ) ;
4055 const image = await Image . decode ( binary ) ;
@@ -50,6 +65,21 @@ const panic = msg => {
5065 if ( ! Buffer . from ( target ) . equals ( Buffer . from ( encoded ) ) ) panic ( 'rotate 180 failed' ) ;
5166 }
5267
68+ {
69+ const binary = await fs . readFile ( './tests/targets/image.png' ) ;
70+ const image = await Image . decode ( binary ) ;
71+ image . rotate ( 270 ) ;
72+
73+ const encoded = await image . encode ( 1 , { creationTime : 0 , software : '' } ) ;
74+
75+ if ( process . env . OVERWRITE_TEST )
76+ await fs . writeFile ( './tests/targets/rotate-270.png' , encoded ) ;
77+
78+ await fs . writeFile ( './tests/targets/rotate-270.png' , encoded ) ;
79+ const target = await fs . readFile ( './tests/targets/rotate-270.png' ) ;
80+ if ( ! Buffer . from ( target ) . equals ( Buffer . from ( encoded ) ) ) panic ( 'rotate 270 failed' ) ;
81+ }
82+
5383 {
5484 const image = new Image ( 512 , 512 ) ;
5585 image . fill ( ( x ) => Image . hslToColor ( x / image . width , 1 , .5 ) ) ;
0 commit comments