diff --git a/tests/test_invalid_input.rs b/tests/test_invalid_input.rs new file mode 100644 index 00000000..465e2e25 --- /dev/null +++ b/tests/test_invalid_input.rs @@ -0,0 +1,30 @@ +use lightningcss::{ + error::{Error, ErrorLocation, ParserError}, + rules::Location, + stylesheet::{ParserOptions, StyleSheet}, +}; + +#[test] +fn value_missing_closing_brace() { + let input = r#" + .corrupt { + color: hsla(120, 62.32%; + } + "#; + + let parsed = StyleSheet::parse(input, ParserOptions::default()).unwrap_err(); + + let expected = Error { + kind: ParserError::InvalidValue, + loc: Some(ErrorLocation::new( + Location { + line: 0, + column: 23, + source_index: 0, + }, + "".to_string(), + )), + }; + + assert_eq!(parsed.to_string(), expected.to_string()); +}