@@ -4,40 +4,132 @@ import { expect, test } from 'vitest';
44
55test ( 'should extract css successfully in bundle' , async ( ) => {
66 const fixturePath = join ( __dirname , 'bundle' ) ;
7- const { contents } = await buildAndGetResults ( { fixturePath, type : 'css' } ) ;
8- const esmFiles = Object . keys ( contents . esm ) ;
9- expect ( esmFiles ) . toMatchInlineSnapshot ( `
7+ const { contents, files } = await buildAndGetResults ( {
8+ fixturePath,
9+ type : 'css' ,
10+ } ) ;
11+
12+ expect ( files . esm ) . toMatchInlineSnapshot ( `
1013 [
1114 "<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css",
1215 ]
1316 ` ) ;
1417
15- const cjsFiles = Object . keys ( contents . cjs ) ;
16- expect ( cjsFiles ) . toMatchInlineSnapshot ( `
18+ expect ( contents . esm ) . toMatchInlineSnapshot ( `
19+ {
20+ "<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
21+ @import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
22+ .lib1 {
23+ color: red;
24+ }
25+
26+ .lib2 {
27+ color: green;
28+ }
29+
30+ .import {
31+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
32+ }
33+
34+ ",
35+ }
36+ ` ) ;
37+
38+ expect ( files . cjs ) . toMatchInlineSnapshot ( `
1739 [
1840 "<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css",
1941 ]
2042 ` ) ;
43+
44+ expect ( contents . cjs ) . toMatchInlineSnapshot ( `
45+ {
46+ "<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
47+ @import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
48+ .lib1 {
49+ color: red;
50+ }
51+
52+ .lib2 {
53+ color: green;
54+ }
55+
56+ .import {
57+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
58+ }
59+
60+ ",
61+ }
62+ ` ) ;
2163} ) ;
2264
2365test ( 'should extract css successfully in bundle-false' , async ( ) => {
2466 const fixturePath = join ( __dirname , 'bundle-false' ) ;
25- const { contents } = await buildAndGetResults ( { fixturePath, type : 'css' } ) ;
26- const esmFiles = Object . keys ( contents . esm ) ;
27- expect ( esmFiles ) . toMatchInlineSnapshot ( `
67+ const { contents, files } = await buildAndGetResults ( {
68+ fixturePath,
69+ type : 'css' ,
70+ } ) ;
71+
72+ expect ( files . esm ) . toMatchInlineSnapshot ( `
2873 [
2974 "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/import.css",
3075 "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib1.css",
3176 "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib2.css",
3277 ]
3378 ` ) ;
79+ expect ( contents . esm ) . toMatchInlineSnapshot ( `
80+ {
81+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/import.css": "@import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css";
82+ @import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css";
83+ @import "lib1.css";
84+ @import "lib2.css";
85+
86+ .import {
87+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
88+ }
89+
90+ ",
91+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib1.css": ".lib1 {
92+ color: red;
93+ }
94+
95+ ",
96+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib2.css": ".lib2 {
97+ color: green;
98+ }
99+
100+ ",
101+ }
102+ ` ) ;
34103
35- const cjsFiles = Object . keys ( contents . cjs ) ;
36- expect ( cjsFiles ) . toMatchInlineSnapshot ( `
104+ expect ( files . cjs ) . toMatchInlineSnapshot ( `
37105 [
38106 "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/import.css",
39107 "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib1.css",
40108 "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib2.css",
41109 ]
42110 ` ) ;
111+ expect ( contents . cjs ) . toMatchInlineSnapshot ( `
112+ {
113+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/import.css": "@import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css";
114+ @import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css";
115+ @import "lib1.css";
116+ @import "lib2.css";
117+
118+ .import {
119+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
120+ }
121+
122+ ",
123+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib1.css": ".lib1 {
124+ color: red;
125+ }
126+
127+ ",
128+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib2.css": ".lib2 {
129+ color: green;
130+ }
131+
132+ ",
133+ }
134+ ` ) ;
43135} ) ;
0 commit comments