Skip to content

Commit 8104fde

Browse files
test: cover parenthesized cn arguments, nested --value parentheses and unknown rotate axes
Refs #687 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 753f418 commit 8104fde

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎libs/extractor/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14744,6 +14744,7 @@ const on = false;
1474414744
"<Box className={twMerge(`p-4`, 'p-2!', 'hover:p-4', 'hover:p-1')} />",
1474514745
r#"<div className="a b c" />"#
1474614746
)]
14747+
#[case("<Box className={cn(('p-4'), 'p-2')} />", r#"<div className="a" />"#)]
1474714748
#[case(
1474814749
"<Box className={cn('p-4', cond && 'p-2')} />",
1474914750
r#"-<div className={cn("p-4", cond && "p-2") || ""} />"#

‎libs/extractor/src/tailwind_custom.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mod tests {
273273
#[serial]
274274
fn functional_utilities_read_their_value_and_modifier() {
275275
set_tailwind_css(
276-
"@theme { --tab-size-github: 8; --color-brand: #0af; --spacing-gutter: 3rem; } @utility tab-* { tab-size: --value(--tab-size-*, integer, [integer]); } @utility pct-* { width: --value(percentage); } @utility lit-* { display: --value('inline-flex', 'grid'); } @utility num-* { line-height: --value(number); } @utility bg-glow-* { background: --value(--color-*, [color]); box-shadow: 0 0 8px --modifier([percentage], number); } @utility gap-* { gap: --value(--spacing-*); } @utility len-* { width: --value([length]); } @utility pc-* { height: --value([percentage]); } @utility many-* { a: --value([url], [number], [unknown]); } @utility q-* { content: \"--value(x\"; } @utility space-* { gap: --spacing(4); } @utility bad-* { width: --value(unknown-type); } @utility mod-* { width: --value(integer); color: --modifier('red'); }",
276+
"@theme { --tab-size-github: 8; --color-brand: #0af; --spacing-gutter: 3rem; } @utility tab-* { tab-size: --value(--tab-size-*, integer, [integer]); } @utility pct-* { width: --value(percentage); } @utility lit-* { display: --value('inline-flex', 'grid'); } @utility num-* { line-height: --value(number); } @utility bg-glow-* { background: --value(--color-*, [color]); box-shadow: 0 0 8px --modifier([percentage], number); } @utility gap-* { gap: --value(--spacing-*); } @utility len-* { width: --value([length]); } @utility pc-* { height: --value([percentage]); } @utility many-* { a: --value([url], [number], [unknown]); } @utility nest-* { a: --value(fn(x), integer); } @utility nest-* { a: --value(fn(x), integer); } @utility q-* { content: \"--value(x\"; } @utility space-* { gap: --spacing(4); } @utility bad-* { width: --value(unknown-type); } @utility mod-* { width: --value(integer); color: --modifier('red'); }",
277277
);
278278
assert_eq!(written("tab-4"), pairs(&[("tab-size", "4")]));
279279
assert_eq!(written("tab-github"), pairs(&[("tab-size", "8")]));
@@ -306,6 +306,8 @@ mod tests {
306306
assert_eq!(declarations_of("len-3px"), None);
307307
assert_eq!(written("many-[1]"), pairs(&[("a", "1")]));
308308
assert_eq!(declarations_of("many-[x]"), None);
309+
assert_eq!(written("nest-4"), pairs(&[("a", "4")]));
310+
assert_eq!(written("nest-4"), pairs(&[("a", "4")]));
309311
for class in ["space-4", "bad-4", "q-1"] {
310312
assert_eq!(declarations_of(class), None, "{class}");
311313
}

‎libs/extractor/src/tailwind_misc.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ mod tests {
879879
#[case("-indent")]
880880
#[case("-table-auto")]
881881
#[case("antialiased-")]
882+
#[case("rotate-w-45")]
883+
#[case("rotate-x")]
884+
#[case("rotate-w-45")]
885+
#[case("rotate-x")]
882886
fn unknown_utilities_stay_as_written(#[case] class: &str) {
883887
assert_eq!(declarations_of(class), None, "{class}");
884888
}

0 commit comments

Comments
 (0)