@@ -92,15 +92,15 @@ fn css_module_test_vals() -> (String, String, String) {
92
92
"#
93
93
. into ( ) ,
94
94
indoc ! { r#"
95
- .foo_EgL3uq {
95
+ .EgL3uq_foo {
96
96
color: red;
97
97
}
98
98
99
- #id_EgL3uq {
100
- animation: test_EgL3uq 2s;
99
+ #EgL3uq_id {
100
+ animation: EgL3uq_test 2s;
101
101
}
102
102
103
- @keyframes test_EgL3uq {
103
+ @keyframes EgL3uq_test {
104
104
from {
105
105
color: red;
106
106
}
@@ -110,15 +110,15 @@ fn css_module_test_vals() -> (String, String, String) {
110
110
}
111
111
}
112
112
113
- @counter-style circles_EgL3uq {
113
+ @counter-style EgL3uq_circles {
114
114
symbols: Ⓐ Ⓑ Ⓒ;
115
115
}
116
116
117
117
ul {
118
- list-style: circles_EgL3uq ;
118
+ list-style: EgL3uq_circles ;
119
119
}
120
120
121
- @keyframes fade_EgL3uq {
121
+ @keyframes EgL3uq_fade {
122
122
from {
123
123
opacity: 0;
124
124
}
@@ -278,6 +278,41 @@ fn css_modules_output_target_option() -> Result<(), Box<dyn std::error::Error>>
278
278
Ok ( ( ) )
279
279
}
280
280
281
+ #[ test]
282
+ fn css_modules_stdout ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
283
+ let ( input, out_code, exports) = css_module_test_vals ( ) ;
284
+ let infile = assert_fs:: NamedTempFile :: new ( "test.css" ) ?;
285
+ infile. write_str ( & input) ?;
286
+ let mut cmd = Command :: cargo_bin ( "parcel_css" ) ?;
287
+ cmd. current_dir ( infile. path ( ) . parent ( ) . unwrap ( ) ) ;
288
+ cmd. arg ( infile. path ( ) ) ;
289
+ cmd. arg ( "--css-modules" ) ;
290
+ let assert = cmd. assert ( ) . success ( ) ;
291
+ let output = assert. get_output ( ) ;
292
+
293
+ let expected: serde_json:: Value = serde_json:: from_str ( & exports) ?;
294
+ let actual: serde_json:: Value = serde_json:: from_slice ( & output. stdout ) ?;
295
+ assert_eq ! ( out_code, actual. pointer( "/code" ) . unwrap( ) . as_str( ) . unwrap( ) ) ;
296
+ assert_eq ! ( & expected, actual. pointer( "/exports" ) . unwrap( ) ) ;
297
+
298
+ Ok ( ( ) )
299
+ }
300
+
301
+ #[ test]
302
+ fn css_modules_pattern ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
303
+ let ( input, _, _) = css_module_test_vals ( ) ;
304
+ let infile = assert_fs:: NamedTempFile :: new ( "test.css" ) ?;
305
+ infile. write_str ( & input) ?;
306
+ let mut cmd = Command :: cargo_bin ( "parcel_css" ) ?;
307
+ cmd. current_dir ( infile. path ( ) . parent ( ) . unwrap ( ) ) ;
308
+ cmd. arg ( infile. path ( ) ) ;
309
+ cmd. arg ( "--css-modules" ) ;
310
+ cmd. arg ( "--css-modules-pattern" ) . arg ( "[name]-[hash]-[local]" ) ;
311
+ cmd. assert ( ) . success ( ) . stdout ( predicate:: str:: contains ( "test-EgL3uq-foo" ) ) ;
312
+
313
+ Ok ( ( ) )
314
+ }
315
+
281
316
#[ test]
282
317
fn sourcemap ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
283
318
let ( input, _, _) = css_module_test_vals ( ) ;
0 commit comments