Skip to content

Commit 41d3f41

Browse files
committed
Add tests
1 parent 1ed473a commit 41d3f41

File tree

1 file changed

+24
-0
lines changed
  • crates/oxide/src/extractor/pre_processors

1 file changed

+24
-0
lines changed

crates/oxide/src/extractor/pre_processors/ruby.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,14 @@ mod tests {
239239
"%w(flex data-[state=pending]:bg-(--my-color) flex-col)",
240240
"%w flex data-[state=pending]:bg-(--my-color) flex-col ",
241241
),
242+
243+
// %w …\n
244+
("%w flex px-2.5\n", "%w flex px-2.5\n"),
245+
242246
// Use backslash to embed spaces in the strings.
243247
(r#"%w[foo\ bar baz\ bat]"#, r#"%w foo bar baz bat "#),
244248
(r#"%W[foo\ bar baz\ bat]"#, r#"%W foo bar baz bat "#),
249+
245250
// The nested delimiters evaluated to a flat array of strings
246251
// (not nested array).
247252
(r#"%w[foo[bar baz]qux]"#, r#"%w foo[bar baz]qux "#),
@@ -257,6 +262,23 @@ mod tests {
257262
r#"def call = tag.span "Foo", class: %w[rounded-full h-0.75 w-0.75]"#,
258263
r#"def call = tag.span "Foo", class: %w rounded-full h-0.75 w-0.75 "#
259264
),
265+
266+
(r#"%w[foo ' bar]"#, r#"%w foo ' bar "#),
267+
(r#"%w[foo " bar]"#, r#"%w foo " bar "#),
268+
(r#"%W[foo ' bar]"#, r#"%W foo ' bar "#),
269+
(r#"%W[foo " bar]"#, r#"%W foo " bar "#),
270+
271+
(r#"%p foo ' bar "#, r#"%p foo ' bar "#),
272+
(r#"%p foo " bar "#, r#"%p foo " bar "#),
273+
274+
(
275+
"%p has a ' quote\n# this should be removed\n%p has a ' quote",
276+
"%p has a ' quote\n \n%p has a ' quote"
277+
),
278+
(
279+
"%p has a \" quote\n# this should be removed\n%p has a \" quote",
280+
"%p has a \" quote\n \n%p has a \" quote"
281+
),
260282
] {
261283
Ruby::test(input, expected);
262284
}
@@ -297,6 +319,8 @@ mod tests {
297319

298320
(r#""foo # bar""#, vec!["foo", "bar"]),
299321
(r#"'foo # bar'"#, vec!["foo", "bar"]),
322+
323+
(r#"%w[foo ' bar]"#, vec!["foo", "bar"]),
300324
] {
301325
Ruby::test_extract_contains(input, expected);
302326
}

0 commit comments

Comments
 (0)