1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import org.htmlunit.SimpleWebTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.htmlunit.junit.annotation.HtmlUnitNYI;
20 import org.junit.jupiter.api.Test;
21
22
23
24
25
26
27
28 public class HtmlWeekInput2Test extends SimpleWebTestCase {
29
30
31
32
33 @Test
34 @Alerts({"true", "false", "true", "true", "true", "true"})
35 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
36 FF_ESR = {"true", "true", "true", "true", "true", "true"})
37 public void minValidation() throws Exception {
38 final String htmlContent = DOCTYPE_HTML
39 + "<html>\n"
40 + "<head></head>\n"
41 + "<body>\n"
42 + "<form id='form1'>\n"
43 + " <input type='week' id='first' min='2018-W10'>\n"
44 + " <input type='week' id='second'>\n"
45 + " <input type='week' id='third' min='foo'>\n"
46 + "</form>\n"
47 + "</body></html>";
48
49 final HtmlPage page = loadPage(htmlContent);
50
51 final HtmlWeekInput first = (HtmlWeekInput) page.getElementById("first");
52 final HtmlWeekInput second = (HtmlWeekInput) page.getElementById("second");
53 final HtmlWeekInput third = (HtmlWeekInput) page.getElementById("third");
54
55
56 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
57
58 first.setValue("2018-W09");
59 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
60
61 first.setValue("2018-W10");
62 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
63
64 first.setValue("2018-W11");
65 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
66
67 second.setValue("2018-W10");
68 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
69 third.setValue("2018-W10");
70 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
71 }
72
73
74
75
76 @Test
77 @Alerts({"true", "true", "true", "false", "true", "true"})
78 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
79 FF_ESR = {"true", "true", "true", "true", "true", "true"})
80 public void naxValidation() throws Exception {
81 final String htmlContent = DOCTYPE_HTML
82 + "<html>\n"
83 + "<head></head>\n"
84 + "<body>\n"
85 + "<form id='form1'>\n"
86 + " <input type='week' id='first' max='2018-W10'>\n"
87 + " <input type='week' id='second'>\n"
88 + " <input type='week' id='third' max='foo'>\n"
89 + "</form>\n"
90 + "</body></html>";
91
92 final HtmlPage page = loadPage(htmlContent);
93
94 final HtmlWeekInput first = (HtmlWeekInput) page.getElementById("first");
95 final HtmlWeekInput second = (HtmlWeekInput) page.getElementById("second");
96 final HtmlWeekInput third = (HtmlWeekInput) page.getElementById("third");
97
98
99 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
100
101 first.setValue("2018-W09");
102 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
103
104 first.setValue("2018-W10");
105 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
106
107 first.setValue("2018-W11");
108 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
109
110 second.setValue("2018-W10");
111 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
112 third.setValue("2018-W10");
113 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
114 }
115 }