From 6efa74d77ec1ec3bc1ea332fa1495dca2ed6b661 Mon Sep 17 00:00:00 2001 From: Hugo Nogueira Date: Thu, 25 Aug 2022 03:54:27 +0100 Subject: [PATCH] fix: Missing semicolon in Custom Media Queries (#260) --- src/rules/custom_media.rs | 3 ++- tests/cli_integration_tests.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/rules/custom_media.rs b/src/rules/custom_media.rs index 78f56b51..2a4b377e 100644 --- a/src/rules/custom_media.rs +++ b/src/rules/custom_media.rs @@ -29,6 +29,7 @@ impl<'i> ToCss for CustomMediaRule<'i> { dest.write_str("@custom-media ")?; self.name.to_css(dest)?; dest.write_char(' ')?; - self.query.to_css(dest) + self.query.to_css(dest)?; + dest.write_char(';') } } diff --git a/tests/cli_integration_tests.rs b/tests/cli_integration_tests.rs index 1eeec239..ca365c4e 100644 --- a/tests/cli_integration_tests.rs +++ b/tests/cli_integration_tests.rs @@ -366,3 +366,22 @@ fn targets() -> Result<(), Box> { Ok(()) } + +#[test] +fn preserve_custom_media() -> Result<(), Box> { + let file = assert_fs::NamedTempFile::new("test.css")?; + file.write_str( + r#" + @custom-media --foo print; + "#, + )?; + + let mut cmd = Command::cargo_bin("parcel_css")?; + cmd.arg(file.path()); + cmd.arg("--custom-media"); + cmd.assert().success().stdout(predicate::str::contains(indoc! {r#" + @custom-media --foo print; + "#})); + + Ok(()) +} \ No newline at end of file