feat: manual props

This commit is contained in:
Jonathan Kelley committed 2022-06-28 17:16:26 -04:00
1 parent 5bab835843
commit fa756ba245
6 files changed
+245 -57

No files matched your search

+49 -9
View File
@@ -1,11 +1,5 @@
use dioxus_autofmt::*;
use proc_macro2::TokenStream as TokenStream2;
use syn::{Attribute, Meta};
fn test_block(wrong: &str, right: &str) {
let formatted = fmt_block(wrong).unwrap();
assert_eq!(formatted, right);
}
fn print_block(wrong: &str) {
let formatted = fmt_block(wrong).unwrap();
@@ -165,10 +159,12 @@ fn format_comments() {
fn formats_component() {
let block = r#"
Component {
adsasd: "asd", // this is a comment
adsasd: "asd",
// this is a comment
onclick: move |_| {
let blah = 120;
let blah = 120;
let blah = 122;
},
}
"#;
@@ -178,6 +174,49 @@ fn formats_component() {
println!("{formatted}");
}
#[test]
fn formats_component_complex() {
let block = r#"
div {
Component {
adsasd: "asd",
onclick: move |_| {
let a = a;
}
div {
"thing"
}
}
Component {
asdasd: "asdasd",
asdasd: "asdasdasdasdasdasdasdasdasdasd",
..Props {
a: 10,
b: 20
}
}
Component {
//
asdasd: "asdasd",
..Props {
a: 10,
b: 20,
c: {
fn main() {
//
}
}
}
"content"
}
}
"#;
let formatted = fmt_block(block).unwrap();
println!("{formatted}");
}
#[test]
fn formats_element() {
let block = r#"
@@ -239,6 +278,7 @@ fn formats_element_nested() {
#[test]
fn formats_element_props_on_top() {
// Gets compressed because there's no real comments
let block = r#"
h3 {
class: "mb-2 text-xl font-bold mb-2 text-xl font-bold mb-2 text-xl font-bold mb-2 text-xl font-bold mb-2 text-xl font-bold",
@@ -580,7 +620,7 @@ fn NavItem<'a>(cx: Scope, to: &'static str, children: Element<'a>, icon: Shape)
#[test]
fn empty_blocks() {
let mut src = r###"
let src = r###"
pub fn Alert(cx: Scope) -> Element {
cx.render(rsx! {
div { }