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 HtmlMonthInput2Test 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='month' id='first' min='2018-12'>\n"
44 + " <input type='month' id='second'>\n"
45 + " <input type='month' id='third' min='foo'>\n"
46 + "</form>\n"
47 + "</body></html>";
48
49 final HtmlPage page = loadPage(htmlContent);
50
51 final HtmlMonthInput first = (HtmlMonthInput) page.getElementById("first");
52 final HtmlMonthInput second = (HtmlMonthInput) page.getElementById("second");
53 final HtmlMonthInput third = (HtmlMonthInput) page.getElementById("third");
54
55
56 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
57
58 first.setValue("2018-11");
59 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
60
61 first.setValue("2018-12");
62 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
63
64 first.setValue("2018-12");
65 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
66
67 second.setValue("2018-11");
68 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
69 assertTrue(second.isValid());
70 third.setValue("2018-11");
71 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
72 }
73
74
75
76
77 @Test
78 @Alerts({"true", "true", "true", "false", "true", "true"})
79 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
80 FF_ESR = {"true", "true", "true", "true", "true", "true"})
81 public void maxValidation() throws Exception {
82 final String htmlContent = DOCTYPE_HTML
83 + "<html>\n"
84 + "<head></head>\n"
85 + "<body>\n"
86 + "<form id='form1'>\n"
87 + " <input type='month' id='first' max='2018-12'>\n"
88 + " <input type='month' id='second'>\n"
89 + " <input type='month' id='third' max='foo'>\n"
90 + "</form>\n"
91 + "</body></html>";
92
93 final HtmlPage page = loadPage(htmlContent);
94
95 final HtmlMonthInput first = (HtmlMonthInput) page.getElementById("first");
96 final HtmlMonthInput second = (HtmlMonthInput) page.getElementById("second");
97 final HtmlMonthInput third = (HtmlMonthInput) page.getElementById("third");
98
99
100 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
101
102 first.setValue("2018-11");
103 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
104
105 first.setValue("2018-12");
106 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
107
108 first.setValue("2019-01");
109 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
110
111 second.setValue("2018-12");
112 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
113 third.setValue("2018-12");
114 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
115 }
116 }