Skip to content

Commit a61c3dc

Browse files
committed
Add testcase
1 parent 68ebd4e commit a61c3dc

5 files changed

Lines changed: 53 additions & 12 deletions

libs/extractor/src/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,25 @@ import clsx from 'clsx'
14011401
.unwrap()
14021402
));
14031403

1404+
reset_class_map();
1405+
reset_file_map();
1406+
assert_debug_snapshot!(ToBTreeSet::from(
1407+
extract(
1408+
"test.tsx",
1409+
r#"import { Box } from "@devup-ui/core";
1410+
<Box bg={left + right} />;
1411+
"#,
1412+
ExtractOption {
1413+
package: "@devup-ui/core".to_string(),
1414+
css_dir: "@devup-ui/core".to_string(),
1415+
single_css: true,
1416+
import_main_css: false,
1417+
import_aliases: HashMap::new()
1418+
}
1419+
)
1420+
.unwrap()
1421+
));
1422+
14041423
reset_class_map();
14051424
reset_file_map();
14061425
assert_debug_snapshot!(ToBTreeSet::from(
@@ -16856,7 +16875,7 @@ export const A = () => <Box _hover={hoverStyle} bg="red" />;
1685616875
css_dir: "@devup-ui/react".to_string(),
1685716876
single_css: true,
1685816877
import_main_css: false,
16859-
import_aliases: HashMap::new(),
16878+
import_aliases: HashMap::new()
1686016879
},
1686116880
)
1686216881
.unwrap()
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
source: libs/extractor/src/lib.rs
3-
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box padding={Math.abs(5)} />;\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}).unwrap())"
3+
assertion_line: 969
4+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box bg={left + right} />;\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())"
45
---
56
ToBTreeSet {
67
styles: {
78
Dynamic(
89
ExtractDynamicStyle {
9-
property: "padding",
10+
property: "background",
1011
level: 0,
11-
identifier: "Math.abs(5)",
12+
identifier: "left+right",
1213
selector: None,
1314
style_order: None,
1415
},
1516
),
1617
},
17-
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": Math.abs(5) }} />;\n",
18+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": left+right }} />;\n",
1819
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
source: libs/extractor/src/lib.rs
3-
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box bg={data.buttonBgColor} />;\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}).unwrap())"
3+
assertion_line: 982
4+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box padding={Math.abs(5)} />;\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())"
45
---
56
ToBTreeSet {
67
styles: {
78
Dynamic(
89
ExtractDynamicStyle {
9-
property: "background",
10+
property: "padding",
1011
level: 0,
11-
identifier: "data.buttonBgColor",
12+
identifier: "Math.abs(5)",
1213
selector: None,
1314
style_order: None,
1415
},
1516
),
1617
},
17-
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": data.buttonBgColor }} />;\n",
18+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": Math.abs(5) }} />;\n",
1819
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
source: libs/extractor/src/lib.rs
3-
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box bg={data.a.b.buttonBgColor} />;\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}).unwrap())"
3+
assertion_line: 995
4+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box bg={data.buttonBgColor} />;\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())"
45
---
56
ToBTreeSet {
67
styles: {
78
Dynamic(
89
ExtractDynamicStyle {
910
property: "background",
1011
level: 0,
11-
identifier: "data.a.b.buttonBgColor",
12+
identifier: "data.buttonBgColor",
1213
selector: None,
1314
style_order: None,
1415
},
1516
),
1617
},
17-
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": data.a.b.buttonBgColor }} />;\n",
18+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": data.buttonBgColor }} />;\n",
1819
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
assertion_line: 1008
4+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box bg={data.a.b.buttonBgColor} />;\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())"
5+
---
6+
ToBTreeSet {
7+
styles: {
8+
Dynamic(
9+
ExtractDynamicStyle {
10+
property: "background",
11+
level: 0,
12+
identifier: "data.a.b.buttonBgColor",
13+
selector: None,
14+
style_order: None,
15+
},
16+
),
17+
},
18+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"a\" style={{ \"--b\": data.a.b.buttonBgColor }} />;\n",
19+
}

0 commit comments

Comments
 (0)