@@ -135,6 +135,66 @@ describe("Puppeteer", function() {
135
135
}
136
136
} ) ;
137
137
138
+ it ( "should render a TIFF" , async ( ) => {
139
+ const engine = new puppeteer . Puppeteer ( ) ;
140
+ await engine . init ( ) ;
141
+
142
+ try {
143
+ const req = {
144
+ query : {
145
+ url : "https://example.com/" ,
146
+ format : "tiff"
147
+ } ,
148
+ body : { }
149
+ } ;
150
+ const res = {
151
+ send : function ( data ) {
152
+ this . data = data ;
153
+ } ,
154
+ type : function ( file ) {
155
+ this . file = file ;
156
+ }
157
+ } ;
158
+ await engine . render ( req , res ) ;
159
+ assert . ok ( res . data ) ;
160
+ assert . strictEqual ( res . file , "tiff" ) ;
161
+ const littleEndian = res . data . slice ( 0 , 4 ) . equals ( Buffer . from ( [ 0x49 , 0x49 , 0x2a , 0x00 ] ) ) ;
162
+ const bigEndian = res . data . slice ( 0 , 4 ) . equals ( Buffer . from ( [ 0x4d , 0x4d , 0x00 , 0x2a ] ) ) ;
163
+ assert . ok ( littleEndian || bigEndian ) ;
164
+ } finally {
165
+ await engine . destroy ( ) ;
166
+ }
167
+ } ) ;
168
+
169
+ it ( "should render a BMP" , async ( ) => {
170
+ const engine = new puppeteer . Puppeteer ( ) ;
171
+ await engine . init ( ) ;
172
+
173
+ try {
174
+ const req = {
175
+ query : {
176
+ url : "https://example.com/" ,
177
+ format : "bmp"
178
+ } ,
179
+ body : { }
180
+ } ;
181
+ const res = {
182
+ send : function ( data ) {
183
+ this . data = data ;
184
+ } ,
185
+ type : function ( file ) {
186
+ this . file = file ;
187
+ }
188
+ } ;
189
+ await engine . render ( req , res ) ;
190
+ assert . ok ( res . data ) ;
191
+ assert . strictEqual ( res . file , "bmp" ) ;
192
+ assert . ok ( res . data . slice ( 0 , 2 ) . equals ( Buffer . from ( [ 0x42 , 0x4d ] ) ) ) ;
193
+ } finally {
194
+ await engine . destroy ( ) ;
195
+ }
196
+ } ) ;
197
+
138
198
it ( "should open new page" , async ( ) => {
139
199
const engine = new puppeteer . Puppeteer ( ) ;
140
200
await engine . init ( ) ;
0 commit comments