Skip to content

Commit 25e0986

Browse files
committed
Fix coverage issue
1 parent 6c55a7b commit 25e0986

File tree

6 files changed

+13
-40
lines changed

6 files changed

+13
-40
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
- run: |
4141
pnpm build
4242
pnpm lint
43+
# rust coverage issue
44+
echo "max_width = 1000\ntab_spaces = 4\nnewline_style = \"Unix\"\nfn_call_width = 1000\nfn_params_layout = \"Compressed\"\nchain_width = 1000\nmerge_derives = true\nuse_small_heuristics = \"Default\"\n" > .rustfmt.toml
45+
cargo fmt
4346
pnpm test
4447
- name: Benchmark
4548
run: pnpm benchmark

libs/css/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ mod tests {
454454
"cls",
455455
Some(&StyleSelector::Media {
456456
query: "print".to_string(),
457-
selector: None,
457+
selector: None
458458
})
459459
),
460460
".cls"
@@ -465,7 +465,7 @@ mod tests {
465465
"cls",
466466
Some(&StyleSelector::Media {
467467
query: "print".to_string(),
468-
selector: Some("&:hover".to_string()),
468+
selector: Some("&:hover".to_string())
469469
})
470470
),
471471
".cls:hover"

libs/css/src/optimize_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn optimize_value(value: &str) -> String {
114114
}
115115

116116
fn optimize_color(value: &str) -> String {
117-
let mut ret = value.to_string().to_uppercase();
117+
let mut ret = value.to_uppercase();
118118

119119
if ret.len() == 6 {
120120
let ch = ret.chars().collect::<Vec<char>>();

libs/extractor/src/css_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn optimize_css_block(css: &str) -> String {
157157
.split(";")
158158
.map(|s| {
159159
if !s.contains(":") {
160-
s.to_string().trim().to_string()
160+
s.trim().to_string()
161161
} else {
162162
let mut iter = s.split(":");
163163
let property = iter.next().unwrap().trim();

libs/extractor/src/gen_class_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn merge_expression_for_class_name<'a>(
124124
let mut unknown_expr = vec![];
125125
for expr in expressions {
126126
if let Expression::StringLiteral(str) = &expr {
127-
class_names.push(str.value.to_string().trim().to_string())
127+
class_names.push(str.value.trim().to_string())
128128
} else {
129129
unknown_expr.push(expr);
130130
}

libs/extractor/src/lib.rs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ mod tests {
200200
r#"import {Box} from '@devup-ui/core'
201201
<Box padding={1} ref={ref} data-test={1} role={2} children={[]} onClick={()=>{}} aria-valuenow={24} key={2} tabIndex={1} id="id" />
202202
"#,
203-
ExtractOption {
204-
package: "@devup-ui/core".to_string(),
205-
css_file: None
206-
}
203+
ExtractOption { package: "@devup-ui/core".to_string(), css_file: None }
207204
)
208205
.unwrap()
209206
));
@@ -2595,37 +2592,13 @@ e(o, { className: "a", bg: variable, style: { color: "blue" }, ...props })
25952592
#[serial]
25962593
fn support_transpile_cjs() {
25972594
reset_class_map();
2598-
assert_debug_snapshot!(ToBTreeSet::from(extract(
2599-
"test.cjs",
2600-
r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#,
2601-
ExtractOption {
2602-
package: "@devup-ui/react".to_string(),
2603-
css_file: None
2604-
}
2605-
)
2606-
.unwrap()));
2595+
assert_debug_snapshot!(ToBTreeSet::from(extract("test.cjs", r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, ExtractOption { package: "@devup-ui/react".to_string(), css_file: None }).unwrap()));
26072596

26082597
reset_class_map();
2609-
assert_debug_snapshot!(ToBTreeSet::from(extract(
2610-
"test.cjs",
2611-
r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const {jsx:e1, jsxs:e2}=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e2("div",{children:[e1(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e1(r.Text,{typography:"header",children:"typo"}),e1(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#,
2612-
ExtractOption {
2613-
package: "@devup-ui/react".to_string(),
2614-
css_file: None
2615-
}
2616-
)
2617-
.unwrap()));
2598+
assert_debug_snapshot!(ToBTreeSet::from(extract("test.cjs", r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const {jsx:e1, jsxs:e2}=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e2("div",{children:[e1(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e1(r.Text,{typography:"header",children:"typo"}),e1(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, ExtractOption { package: "@devup-ui/react".to_string(), css_file: None }).unwrap()));
26182599

26192600
reset_class_map();
2620-
assert_debug_snapshot!(ToBTreeSet::from(extract(
2621-
"test.js",
2622-
r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#,
2623-
ExtractOption {
2624-
package: "@devup-ui/react".to_string(),
2625-
css_file: None
2626-
}
2627-
)
2628-
.unwrap()));
2601+
assert_debug_snapshot!(ToBTreeSet::from(extract("test.js", r#""use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@devup-ui/react");function t(){return e.jsxs("div",{children:[e.jsx(r.Box,{_hover:{bg:"blue"},bg:"$text",color:"red",children:"hello"}),e.jsx(r.Text,{typography:"header",children:"typo"}),e.jsx(r.Flex,{as:"section",mt:2,children:"section"})]})}exports.Lib=t;"#, ExtractOption { package: "@devup-ui/react".to_string(), css_file: None }).unwrap()));
26292602
}
26302603

26312604
#[test]
@@ -2638,10 +2611,7 @@ e(o, { className: "a", bg: variable, style: { color: "blue" }, ...props })
26382611
r#"import {Flex} from '@devup-ui/core'
26392612
<Flex opacity={1} zIndex={2} fontWeight={900} scale={2} flex={1} lineHeight={1} tabSize={4} MozTabSize={4} />
26402613
"#,
2641-
ExtractOption {
2642-
package: "@devup-ui/core".to_string(),
2643-
css_file: None
2644-
}
2614+
ExtractOption { package: "@devup-ui/core".to_string(), css_file: None }
26452615
)
26462616
.unwrap()
26472617
));

0 commit comments

Comments
 (0)