{move_tr!("select-a-language")}
+{move_tr!("html-tag-lang-is", { "foo" => "value1", "bar" => "value2" })}
+ } + } + }; + let tr_macros = tr_macros_from_file_content(&content.to_string()); + + assert_eq!( + tr_macros, + vec![ + tr_macro!("move_tr", "select-a-language", Vec::new()), + tr_macro!( + "move_tr", + "html-tag-lang-is", + vec!["foo".to_string(), "bar".to_string(),] + ), + ] + ); + } + + #[test] + fn tr_macros_from_closure() { + let content = quote! { + fn App() -> impl IntoView { + let closure_a = move || tr!("select-a-language"); + let closure_b = move || { + tr!("html-tag-lang-is", { "foo" => "value1", "bar" => "value2" }); + }; + let closure_c = || tr!("select-another-language"); + let closure_d = || { + tr!("other-html-tag-lang-is", { "foo" => "value1", "bar" => "value2" }); + }; + } + }; + let tr_macros = tr_macros_from_file_content(&content.to_string()); + + assert_eq!( + tr_macros, + vec![ + tr_macro!("tr", "select-a-language", Vec::new()), + tr_macro!( + "tr", + "html-tag-lang-is", + vec!["foo".to_string(), "bar".to_string(),] + ), + tr_macro!("tr", "select-another-language", Vec::new()), + tr_macro!( + "tr", + "other-html-tag-lang-is", + vec!["foo".to_string(), "bar".to_string(),] + ), + ] + ); + } + + #[test] + fn tr_macros_from_stmt_macros() { + let content = quote! { + fn App() -> impl IntoView { + // for completeness, this is not idiomatic + tr!("select-a-language"); + tr!("html-tag-lang-is", { "foo" => "value1", "bar" => "value2" }); + } + }; + let tr_macros = tr_macros_from_file_content(&content.to_string()); + + assert_eq!( + tr_macros, + vec![ + tr_macro!("tr", "select-a-language", Vec::new()), + tr_macro!( + "tr", + "html-tag-lang-is", + vec!["foo".to_string(), "bar".to_string(),] + ), + ] + ); + } + + #[test] + fn tr_macros_from_stmt() { + let content = quote! { + fn App() -> impl IntoView { + let a = tr!("select-a-language"); + let b = tr!("html-tag-lang-is", { "foo" => "value1", "bar" => "value2" }); + } + }; + let tr_macros = tr_macros_from_file_content(&content.to_string()); + + assert_eq!( + tr_macros, + vec![ + tr_macro!("tr", "select-a-language", Vec::new()), + tr_macro!( + "tr", + "html-tag-lang-is", + vec!["foo".to_string(), "bar".to_string(),] + ), + ] + ); + } + + #[test] + fn tr_macros_from_if_inside_view_macro() { + let content = quote! { + fn App() -> impl IntoView { + view! { +