Skip to content

Commit 6c55753

Browse files
committed
Add testcase
1 parent ee425e8 commit 6c55753

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

libs/extractor/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,6 +4188,35 @@ import clsx from 'clsx'
41884188
)
41894189
.unwrap()
41904190
));
4191+
4192+
reset_class_map();
4193+
reset_file_map();
4194+
// ParenthesizedExpression wrapping object in computed member
4195+
assert_debug_snapshot!(ToBTreeSet::from(
4196+
extract(
4197+
"test.tsx",
4198+
r#"import {Text} from '@devup-ui/core'
4199+
<Text
4200+
typography={({
4201+
lg: "buttonLg",
4202+
md: "button",
4203+
sm: "buttonSm",
4204+
tag: "tag"
4205+
})[size]}
4206+
>
4207+
{children}
4208+
</Text>
4209+
"#,
4210+
ExtractOption {
4211+
package: "@devup-ui/core".to_string(),
4212+
css_dir: "@devup-ui/core".to_string(),
4213+
single_css: true,
4214+
import_main_css: false,
4215+
import_aliases: HashMap::new()
4216+
}
4217+
)
4218+
.unwrap()
4219+
));
41914220
}
41924221

41934222
#[test]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import {Text} from '@devup-ui/core'\n <Text\n typography={({\n lg: \"buttonLg\",\n md: \"button\",\n sm: \"buttonSm\",\n tag: \"tag\"\n })[size]}\n >\n {children}\n </Text>\n \"#,\nExtractOption\n{\n package: \"@devup-ui/core\".to_string(), css_dir:\n \"@devup-ui/core\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n}).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Typography(
8+
"button",
9+
),
10+
Typography(
11+
"buttonLg",
12+
),
13+
Typography(
14+
"buttonSm",
15+
),
16+
Typography(
17+
"tag",
18+
),
19+
},
20+
code: "import \"@devup-ui/core/devup-ui.css\";\n<span className={{\n\t\"lg\": \"typo-buttonLg\",\n\t\"md\": \"typo-button\",\n\t\"sm\": \"typo-buttonSm\",\n\t\"tag\": \"typo-tag\"\n}[size] || \"\"}>\n {children}\n </span>;\n",
21+
}

0 commit comments

Comments
 (0)