@@ -6,13 +6,18 @@ import { importSvgCollection, importSvgCollections } from './iconify'
66
77const assetsPath = path . resolve ( __dirname , 'assets' )
88
9+ function omitLastModified < T extends { lastModified ?: number } > ( obj : T ) : Omit < T , 'lastModified' > {
10+ const { lastModified : _ , ...rest } = obj
11+ return rest
12+ }
13+
914describe ( 'importSvgCollection' , ( ) => {
1015 it ( 'should import SVG collection' , async ( ) => {
1116 const result = await importSvgCollection ( {
1217 source : path . join ( assetsPath , 'vender/line' ) ,
1318 } )
1419
15- expect ( result ) . toMatchInlineSnapshot ( `
20+ expect ( omitLastModified ( result ) ) . toMatchInlineSnapshot ( `
1621 {
1722 "icons": {
1823 "alert-triangle": {
@@ -31,7 +36,6 @@ describe('importSvgCollection', () => {
3136 "body": "<g fill="none"><g clip-path="url(#svgID0)"><path stroke="#667085" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.333 1.334v7.333m3.334-2.133V3.467c0-.746 0-1.12-.146-1.405a1.33 1.33 0 0 0-.582-.583c-.286-.145-.659-.145-1.406-.145H5.412c-.974 0-1.462 0-1.855.178a2 2 0 0 0-.85.73c-.236.36-.31.842-.458 1.805L1.9 6.314c-.195 1.27-.293 1.905-.104 2.4a2 2 0 0 0 .88 1.025c.46.262 1.102.262 2.387.262H5.6c.373 0 .56 0 .703.072a.67.67 0 0 1 .291.292c.073.142.073.329.073.702v1.956c0 .908.736 1.644 1.644 1.644a.55.55 0 0 0 .5-.325l2.24-5.041c.103-.23.154-.344.234-.428a.7.7 0 0 1 .256-.166c.11-.04.235-.04.486-.04h.506c.747 0 1.12 0 1.406-.145c.25-.128.454-.332.582-.583c.146-.285.146-.658.146-1.405"/></g><defs><clipPath id="svgID0"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></g>",
3237 },
3338 },
34- "lastModified": 1769863589,
3539 "prefix": "line",
3640 }
3741 ` )
@@ -43,27 +47,34 @@ describe('importSvgCollection', () => {
4347 includeSubDirs : false ,
4448 } )
4549
46- expect ( result ) . toMatchInlineSnapshot ( `
50+ expect ( omitLastModified ( result ) ) . toMatchInlineSnapshot ( `
4751 {
4852 "icons": {
4953 "copy": {
5054 "body": "<path fill="none" stroke="#667085" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.667 2.666H12A1.333 1.333 0 0 1 13.333 4v9.333A1.333 1.333 0 0 1 12 14.666H4a1.333 1.333 0 0 1-1.333-1.333V4A1.333 1.333 0 0 1 4 2.666h1.333M6 1.333h4c.368 0 .666.298.666.667v1.333A.667.667 0 0 1 10 4H6a.667.667 0 0 1-.667-.667V2c0-.369.299-.667.667-.667"/>",
5155 },
5256 },
53- "lastModified": 1769863589,
5457 "prefix": "vender",
5558 }
5659 ` )
5760 } )
5861} )
5962
63+ function omitLastModifiedFromCollections (
64+ collections : Record < string , { lastModified ?: number } > ,
65+ ) : Record < string , Omit < typeof collections [ string ] , 'lastModified' > > {
66+ return Object . fromEntries (
67+ Object . entries ( collections ) . map ( ( [ key , value ] ) => [ key , omitLastModified ( value ) ] ) ,
68+ )
69+ }
70+
6071describe ( 'importSvgCollections' , ( ) => {
6172 it ( 'should import nested directory structure as separate collections' , async ( ) => {
6273 const result = await importSvgCollections ( {
6374 source : assetsPath ,
6475 } )
6576
66- expect ( result ) . toMatchInlineSnapshot ( `
77+ expect ( omitLastModifiedFromCollections ( result ) ) . toMatchInlineSnapshot ( `
6778 {
6879 "public-avatar": {
6980 "icons": {
@@ -73,7 +84,6 @@ describe('importSvgCollections', () => {
7384 "width": 512,
7485 },
7586 },
76- "lastModified": 1769863589,
7787 "prefix": "public-avatar",
7888 },
7989 "vender": {
@@ -82,7 +92,6 @@ describe('importSvgCollections', () => {
8292 "body": "<path fill="none" stroke="#667085" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.667 2.666H12A1.333 1.333 0 0 1 13.333 4v9.333A1.333 1.333 0 0 1 12 14.666H4a1.333 1.333 0 0 1-1.333-1.333V4A1.333 1.333 0 0 1 4 2.666h1.333M6 1.333h4c.368 0 .666.298.666.667v1.333A.667.667 0 0 1 10 4H6a.667.667 0 0 1-.667-.667V2c0-.369.299-.667.667-.667"/>",
8393 },
8494 },
85- "lastModified": 1769863589,
8695 "prefix": "vender",
8796 },
8897 "vender-line-alertsAndFeedback": {
@@ -94,7 +103,6 @@ describe('importSvgCollections', () => {
94103 "body": "<g fill="none"><g clip-path="url(#svgID0)"><path stroke="#667085" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.333 1.334v7.333m3.334-2.133V3.467c0-.746 0-1.12-.146-1.405a1.33 1.33 0 0 0-.582-.583c-.286-.145-.659-.145-1.406-.145H5.412c-.974 0-1.462 0-1.855.178a2 2 0 0 0-.85.73c-.236.36-.31.842-.458 1.805L1.9 6.314c-.195 1.27-.293 1.905-.104 2.4a2 2 0 0 0 .88 1.025c.46.262 1.102.262 2.387.262H5.6c.373 0 .56 0 .703.072a.67.67 0 0 1 .291.292c.073.142.073.329.073.702v1.956c0 .908.736 1.644 1.644 1.644a.55.55 0 0 0 .5-.325l2.24-5.041c.103-.23.154-.344.234-.428a.7.7 0 0 1 .256-.166c.11-.04.235-.04.486-.04h.506c.747 0 1.12 0 1.406-.145c.25-.128.454-.332.582-.583c.146-.285.146-.658.146-1.405"/></g><defs><clipPath id="svgID0"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></g>",
95104 },
96105 },
97- "lastModified": 1769863589,
98106 "prefix": "vender-line-alertsAndFeedback",
99107 },
100108 "vender-line-arrows": {
@@ -109,7 +117,6 @@ describe('importSvgCollections', () => {
109117 "width": 14,
110118 },
111119 },
112- "lastModified": 1769863589,
113120 "prefix": "vender-line-arrows",
114121 },
115122 "vender-pipeline": {
@@ -118,7 +125,6 @@ describe('importSvgCollections', () => {
118125 "body": "<g fill="#354052"><path fill-rule="evenodd" d="M11.333 1.667a.667.667 0 0 0-1.333 0v12.666a.667.667 0 1 0 1.333 0v-1h1.334a2 2 0 0 0 2-2V4.667a2 2 0 0 0-2-2h-1.334zM12.667 12h-1.334V4h1.334c.368 0 .666.298.666.667v6.666a.667.667 0 0 1-.666.667" clip-rule="evenodd"/><path d="M8.667 13.333V12H3.333a.667.667 0 0 1-.666-.667V4.667c0-.369.298-.667.666-.667h5.334V2.667H3.333a2 2 0 0 0-2 2v6.666a2 2 0 0 0 2 2z"/><path d="M8.667 5.249a1 1 0 0 0-.106-.004l-.046.002c-.53.02-1.028.267-1.363.68l-.572.708l-.138-.413a1.25 1.25 0 0 0-1.235-.847l-.726.028a.667.667 0 0 0 .052 1.333l.666-.026l.386 1.155l-1.108 1.37a.5.5 0 0 1-.377.186l-.047.002a.667.667 0 1 0 .052 1.332l.047-.002a1.84 1.84 0 0 0 1.362-.68l.573-.708l.138.413a1.25 1.25 0 0 0 1.257.846l1.185-.087V9.2l-1.2.088l-.386-1.153l1.108-1.37a.5.5 0 0 1 .377-.186l.047-.002l.054-.004z"/></g>",
119126 },
120127 },
121- "lastModified": 1769863589,
122128 "prefix": "vender-pipeline",
123129 },
124130 }
0 commit comments