-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
html_macro_test.rs
42 lines (37 loc) · 999 Bytes
/
html_macro_test.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use yew::{html, html_nested};
#[allow(dead_code)]
#[rustversion::attr(stable(1.51), test)]
fn html_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/html_macro/*-pass.rs");
t.compile_fail("tests/html_macro/*-fail.rs");
}
#[test]
#[should_panic(
expected = "a dynamic tag tried to create a `<br>` tag with children. `<br>` is a void element which can't have any children."
)]
fn dynamic_tags_catch_void_elements() {
html! {
<@{"br"}>
<span>{ "No children allowed" }</span>
</@>
};
}
#[test]
#[should_panic(expected = "a dynamic tag returned a tag name containing non ASCII characters: `❤`")]
fn dynamic_tags_catch_non_ascii() {
html! {
<@{"❤"}/>
};
}
/// test that compilation on html elements pass
/// fixes: https://github.com/yewstack/yew/issues/2268
#[test]
fn html_nested_macro_on_html_element() {
let _node = html_nested! {
<div/>
};
let _node = html_nested! {
<input/>
};
}