11import { execSync } from "node:child_process" ;
22import fs from "node:fs" ;
33import { join } from "node:path" ;
4- import path from "node:path" ;
54
65describe ( "Icon Validation" , ( ) => {
76 const cliPath = join ( __dirname , "../dist/cli/cli.js" ) ;
@@ -18,20 +17,81 @@ describe("Icon Validation", () => {
1817
1918 // Create a valid PNG file (1x1 transparent pixel)
2019 const validPngBuffer = Buffer . from ( [
21- 0x89 , 0x50 , 0x4e , 0x47 , 0x0d , 0x0a , 0x1a , 0x0a , // PNG signature
22- 0x00 , 0x00 , 0x00 , 0x0d , 0x49 , 0x48 , 0x44 , 0x52 , // IHDR chunk
23- 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 , // 1x1 dimensions
24- 0x08 , 0x06 , 0x00 , 0x00 , 0x00 , 0x1f , 0x15 , 0xc4 ,
25- 0x89 , 0x00 , 0x00 , 0x00 , 0x0a , 0x49 , 0x44 , 0x41 ,
26- 0x54 , 0x78 , 0x9c , 0x63 , 0x00 , 0x01 , 0x00 , 0x00 ,
27- 0x05 , 0x00 , 0x01 , 0x0d , 0x0a , 0x2d , 0xb4 , 0x00 ,
28- 0x00 , 0x00 , 0x00 , 0x49 , 0x45 , 0x4e , 0x44 , 0xae ,
29- 0x42 , 0x60 , 0x82 ,
20+ 0x89 ,
21+ 0x50 ,
22+ 0x4e ,
23+ 0x47 ,
24+ 0x0d ,
25+ 0x0a ,
26+ 0x1a ,
27+ 0x0a , // PNG signature
28+ 0x00 ,
29+ 0x00 ,
30+ 0x00 ,
31+ 0x0d ,
32+ 0x49 ,
33+ 0x48 ,
34+ 0x44 ,
35+ 0x52 , // IHDR chunk
36+ 0x00 ,
37+ 0x00 ,
38+ 0x00 ,
39+ 0x01 ,
40+ 0x00 ,
41+ 0x00 ,
42+ 0x00 ,
43+ 0x01 , // 1x1 dimensions
44+ 0x08 ,
45+ 0x06 ,
46+ 0x00 ,
47+ 0x00 ,
48+ 0x00 ,
49+ 0x1f ,
50+ 0x15 ,
51+ 0xc4 ,
52+ 0x89 ,
53+ 0x00 ,
54+ 0x00 ,
55+ 0x00 ,
56+ 0x0a ,
57+ 0x49 ,
58+ 0x44 ,
59+ 0x41 ,
60+ 0x54 ,
61+ 0x78 ,
62+ 0x9c ,
63+ 0x63 ,
64+ 0x00 ,
65+ 0x01 ,
66+ 0x00 ,
67+ 0x00 ,
68+ 0x05 ,
69+ 0x00 ,
70+ 0x01 ,
71+ 0x0d ,
72+ 0x0a ,
73+ 0x2d ,
74+ 0xb4 ,
75+ 0x00 ,
76+ 0x00 ,
77+ 0x00 ,
78+ 0x00 ,
79+ 0x49 ,
80+ 0x45 ,
81+ 0x4e ,
82+ 0x44 ,
83+ 0xae ,
84+ 0x42 ,
85+ 0x60 ,
86+ 0x82 ,
3087 ] ) ;
3188 fs . writeFileSync ( join ( testFixturesDir , "valid-icon.png" ) , validPngBuffer ) ;
3289
3390 // Create an invalid (non-PNG) file
34- fs . writeFileSync ( join ( testFixturesDir , "invalid-icon.jpg" ) , "Not a PNG file" ) ;
91+ fs . writeFileSync (
92+ join ( testFixturesDir , "invalid-icon.jpg" ) ,
93+ "Not a PNG file" ,
94+ ) ;
3595
3696 // Create test manifests
3797 createTestManifest ( "valid-local-icon.json" , {
@@ -92,7 +152,7 @@ describe("Icon Validation", () => {
92152
93153 fs . writeFileSync (
94154 join ( testFixturesDir , filename ) ,
95- JSON . stringify ( manifest , null , 2 )
155+ JSON . stringify ( manifest , null , 2 ) ,
96156 ) ;
97157 }
98158
@@ -135,7 +195,10 @@ describe("Icon Validation", () => {
135195 } ) ;
136196
137197 it ( "should reject icons with ${__dirname} variable" , ( ) => {
138- const manifestPath = join ( testFixturesDir , "invalid-dirname-variable.json" ) ;
198+ const manifestPath = join (
199+ testFixturesDir ,
200+ "invalid-dirname-variable.json" ,
201+ ) ;
139202
140203 expect ( ( ) => {
141204 execSync ( `node ${ cliPath } validate ${ manifestPath } ` , {
@@ -149,8 +212,9 @@ describe("Icon Validation", () => {
149212 encoding : "utf-8" ,
150213 stdio : "pipe" ,
151214 } ) ;
152- } catch ( error : any ) {
153- const output = error . stdout ?. toString ( ) || "" ;
215+ } catch ( error : unknown ) {
216+ const execError = error as { stdout ?: Buffer ; stderr ?: Buffer } ;
217+ const output = execError . stdout ?. toString ( ) || "" ;
154218 expect ( output ) . toContain ( "Icon validation failed" ) ;
155219 expect ( output ) . toContain ( "${__dirname}" ) ;
156220 expect ( output ) . toContain ( "simple relative path" ) ;
@@ -172,8 +236,9 @@ describe("Icon Validation", () => {
172236 encoding : "utf-8" ,
173237 stdio : "pipe" ,
174238 } ) ;
175- } catch ( error : any ) {
176- const output = error . stdout ?. toString ( ) || "" ;
239+ } catch ( error : unknown ) {
240+ const execError = error as { stdout ?: Buffer ; stderr ?: Buffer } ;
241+ const output = execError . stdout ?. toString ( ) || "" ;
177242 expect ( output ) . toContain ( "Icon validation failed" ) ;
178243 expect ( output ) . toContain ( "relative to the bundle root" ) ;
179244 }
@@ -194,8 +259,9 @@ describe("Icon Validation", () => {
194259 encoding : "utf-8" ,
195260 stdio : "pipe" ,
196261 } ) ;
197- } catch ( error : any ) {
198- const output = error . stdout ?. toString ( ) || "" ;
262+ } catch ( error : unknown ) {
263+ const execError = error as { stdout ?: Buffer ; stderr ?: Buffer } ;
264+ const output = execError . stdout ?. toString ( ) || "" ;
199265 expect ( output ) . toContain ( "Icon validation failed" ) ;
200266 expect ( output ) . toContain ( "not found" ) ;
201267 }
@@ -216,8 +282,9 @@ describe("Icon Validation", () => {
216282 encoding : "utf-8" ,
217283 stdio : "pipe" ,
218284 } ) ;
219- } catch ( error : any ) {
220- const output = error . stdout ?. toString ( ) || "" ;
285+ } catch ( error : unknown ) {
286+ const execError = error as { stdout ?: Buffer ; stderr ?: Buffer } ;
287+ const output = execError . stdout ?. toString ( ) || "" ;
221288 expect ( output ) . toContain ( "Icon validation failed" ) ;
222289 expect ( output ) . toContain ( "PNG format" ) ;
223290 }
@@ -233,23 +300,23 @@ describe("Icon Validation", () => {
233300 }
234301
235302 const validPngBuffer = Buffer . from ( [
236- 0x89 , 0x50 , 0x4e , 0x47 , 0x0d , 0x0a , 0x1a , 0x0a ,
237- 0x00 , 0x00 , 0x00 , 0x0d , 0x49 , 0x48 , 0x44 , 0x52 ,
238- 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 ,
239- 0x08 , 0x06 , 0x00 , 0x00 , 0x00 , 0x1f , 0x15 , 0xc4 ,
240- 0x89 , 0x00 , 0x00 , 0x00 , 0x0a , 0x49 , 0x44 , 0x41 ,
241- 0x54 , 0x78 , 0x9c , 0x63 , 0x00 , 0x01 , 0x00 , 0x00 ,
242- 0x05 , 0x00 , 0x01 , 0x0d , 0x0a , 0x2d , 0xb4 , 0x00 ,
243- 0x00 , 0x00 , 0x00 , 0x49 , 0x45 , 0x4e , 0x44 , 0xae ,
244- 0x42 , 0x60 , 0x82 ,
303+ 0x89 , 0x50 , 0x4e , 0x47 , 0x0d , 0x0a , 0x1a , 0x0a , 0x00 , 0x00 , 0x00 , 0x0d ,
304+ 0x49 , 0x48 , 0x44 , 0x52 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 ,
305+ 0x08 , 0x06 , 0x00 , 0x00 , 0x00 , 0x1f , 0x15 , 0xc4 , 0x89 , 0x00 , 0x00 , 0x00 ,
306+ 0x0a , 0x49 , 0x44 , 0x41 , 0x54 , 0x78 , 0x9c , 0x63 , 0x00 , 0x01 , 0x00 , 0x00 ,
307+ 0x05 , 0x00 , 0x01 , 0x0d , 0x0a , 0x2d , 0xb4 , 0x00 , 0x00 , 0x00 , 0x00 , 0x49 ,
308+ 0x45 , 0x4e , 0x44 , 0xae , 0x42 , 0x60 , 0x82 ,
245309 ] ) ;
246310 fs . writeFileSync ( join ( assetsDir , "icon.png" ) , validPngBuffer ) ;
247311
248312 createTestManifest ( "valid-subdirectory-icon.json" , {
249313 icon : "assets/icon.png" ,
250314 } ) ;
251315
252- const manifestPath = join ( testFixturesDir , "valid-subdirectory-icon.json" ) ;
316+ const manifestPath = join (
317+ testFixturesDir ,
318+ "valid-subdirectory-icon.json" ,
319+ ) ;
253320 const result = execSync ( `node ${ cliPath } validate ${ manifestPath } ` , {
254321 encoding : "utf-8" ,
255322 } ) ;
@@ -258,6 +325,4 @@ describe("Icon Validation", () => {
258325 expect ( result ) . toContain ( "Icon validation passed" ) ;
259326 } ) ;
260327 } ) ;
261-
262328} ) ;
263-
0 commit comments