From cceb585777c4a897f3cdbb2c2c52a703353bec17 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 30 Nov 2022 00:38:08 +0100 Subject: [PATCH] add failing tests I noticed that some of the tests were failing, and while looking at them, it happened because the tests were structured like this: ```html
``` This means that the class names themselves eventually end up like this: `backdrop-filter-none\n` -> (Notice the `\n`) /cc @thecrypticace --- oxide/crates/core/src/parser.rs | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/oxide/crates/core/src/parser.rs b/oxide/crates/core/src/parser.rs index 41ba212ed..b8569afe4 100644 --- a/oxide/crates/core/src/parser.rs +++ b/oxide/crates/core/src/parser.rs @@ -564,6 +564,49 @@ mod test { assert_eq!(candidates, vec!["content-['hello_[_]_world']"]); } + #[test] + fn it_should_ignore_leading_spaces() { + let candidates = run(" backdrop-filter-none", false); + assert_eq!(candidates, vec!["backdrop-filter-none"]); + } + + #[test] + fn it_should_ignore_trailing_spaces() { + let candidates = run("backdrop-filter-none ", false); + assert_eq!(candidates, vec!["backdrop-filter-none"]); + } + + #[test] + fn it_should_keep_classes_before_an_ending_newline() { + let candidates = run("backdrop-filter-none\n", false); + assert_eq!(candidates, vec!["backdrop-filter-none"]); + } + + #[test] + fn it_should_parse_out_the_correct_classes_from_tailwind_tests() { + // From: tests/arbitrary-variants.test.js + let candidates = run( + r#" +
+ +
+
+ "#, + false, + ); + // TODO: it should not include additional (separate) classes: class, hover:, foo: bar, underline + // TODO: Double check the expectations based on above information + assert_eq!( + candidates, + vec![ + "class", + r#"dark:lg:hover:[&>*]:underline"#, + r#"[&_.foo\_\_bar]:hover:underline"#, + r#"hover:[&_.foo\_\_bar]:underline"# + ] + ); + } + #[test] fn potential_candidates_are_skipped_when_hitting_impossible_characters() { let candidates = run("

A new software update is available. See what’s new in version 2.0.4.

", false);