1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.bean.html5;
18
19 import static org.apache.juneau.bean.html5.HtmlBuilder.*;
20 import static org.apache.juneau.junit.bct.BctAssertions.*;
21 import static org.junit.jupiter.api.Assertions.*;
22
23 import org.apache.juneau.*;
24 import org.junit.jupiter.api.*;
25
26 class HtmlElement_Test extends TestBase {
27
28 @Test void a01_getAttr_withNull() {
29 A x = a();
30 assertNull(x.getAttr(String.class, "nonexistent"));
31 }
32
33 @Test void a02_getAttr_withValue() {
34 A x = a().href("test");
35 assertString("test", x.getAttr(String.class, "href"));
36 }
37
38 @Test void a03_deminimize() {
39 Button x1 = button().disabled(true);
40 assertString("<button disabled='disabled'></button>", x1);
41
42 Button x2 = button().disabled(false);
43 assertString("<button></button>", x2);
44
45 Button x3 = button().disabled("custom");
46 assertString("<button disabled='custom'></button>", x3);
47 }
48
49 @Test void a04_attr_withNull() {
50 A x = a().href("test");
51 assertString("<a href='test'></a>", x);
52 x.attr("href", null);
53 assertString("<a></a>", x);
54 }
55
56 @Test void a05_attr_urlConversion() {
57 A x = a();
58 x.attr("url", "http://example.com");
59 assertString("http://example.com", x.getAttr(String.class, "url"));
60
61 A x2 = a();
62 x2.attr("href", "http://example.com");
63 assertString("http://example.com", x2.getAttr(String.class, "href"));
64
65 Form x3 = form();
66 x3.attr("action", "http://example.com");
67 assertString("http://example.com", x3.getAttr(String.class, "action"));
68 }
69 }