Skip to content

Commit 0268f5d

Browse files
unit test more html-form
1 parent b155842 commit 0268f5d

File tree

1 file changed

+106
-1
lines changed

1 file changed

+106
-1
lines changed

tests/008_html.test.sh

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "./lib/bashunit_ext"
44
pabin=./parseArger
55
ex=("$pabin" generate)
66
exp=("$pabin" html-form)
7-
spos=("my-arg" "'An argument'")
7+
spos=("my-arg" "'An argument'" --one-of val --one-of val1 --one-of val2)
88
sopt=("my-opt" "'An opt'" -r -s o --alias opt-pt --default-value "'aValue'")
99
sflg=("my-flag" "'A flag'" -s f --no-name nope --alias flg --no-alias noflg --on)
1010
snst=("my-nst" "'A nested opt'")
@@ -85,6 +85,21 @@ function test_html_input_class() {
8585
rm "$tfile";
8686
}
8787

88+
function test_html_input_container_class() {
89+
local tfile="${tftmp_file}_html_input_container_class";
90+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
91+
local pex_=("${exp[@]}" "$tfile" --input-container-class "my-input-class")
92+
93+
assert_exit_code "0" "$("${ex_[@]}")";
94+
assert_is_file "$tfile";
95+
96+
local pexout="$("${pex_[@]}")";
97+
assert_exit_code "0" "$?";
98+
assert_contains "my-input-class" "$pexout";
99+
100+
rm "$tfile";
101+
}
102+
88103
function test_html_label_class() {
89104
local tfile="${tftmp_file}_html_label_class";
90105
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
@@ -97,5 +112,95 @@ function test_html_label_class() {
97112
assert_exit_code "0" "$?";
98113
assert_contains "my-label-class" "$pexout";
99114

115+
rm "$tfile";
116+
}
117+
118+
function test_html_select_class() {
119+
local tfile="${tftmp_file}_html_select_class";
120+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
121+
local pex_=("${exp[@]}" "$tfile" --select-class "my-select-class")
122+
123+
assert_exit_code "0" "$("${ex_[@]}")";
124+
assert_is_file "$tfile";
125+
126+
local pexout="$("${pex_[@]}")";
127+
assert_exit_code "0" "$?";
128+
assert_contains "my-select-class" "$pexout";
129+
130+
rm "$tfile";
131+
}
132+
133+
function test_html_checkbox_label_class() {
134+
local tfile="${tftmp_file}_html_checkbox_label_class";
135+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
136+
local pex_=("${exp[@]}" "$tfile" --checkbox-label-class "my-checkbox-label-class")
137+
138+
assert_exit_code "0" "$("${ex_[@]}")";
139+
assert_is_file "$tfile";
140+
141+
local pexout="$("${pex_[@]}")";
142+
assert_exit_code "0" "$?";
143+
assert_contains "my-checkbox-label-class" "$pexout";
144+
145+
rm "$tfile";
146+
}
147+
148+
function test_html_checkbox_class() {
149+
local tfile="${tftmp_file}_html_checkbox_class";
150+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
151+
local pex_=("${exp[@]}" "$tfile" --checkbox-class "my-checkbox-class")
152+
153+
assert_exit_code "0" "$("${ex_[@]}")";
154+
assert_is_file "$tfile";
155+
156+
local pexout="$("${pex_[@]}")";
157+
assert_exit_code "0" "$?";
158+
assert_contains "my-checkbox-class" "$pexout";
159+
160+
rm "$tfile";
161+
}
162+
163+
function test_html_no_form() {
164+
local tfile="${tftmp_file}_html_no_form";
165+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
166+
local pex_=("${exp[@]}" "$tfile" --no-form)
167+
168+
assert_exit_code "0" "$("${ex_[@]}")";
169+
assert_is_file "$tfile";
170+
171+
local pexout="$("${pex_[@]}")";
172+
assert_exit_code "0" "$?";
173+
assert_not_contains "<form" "$pexout";
174+
175+
rm "$tfile";
176+
}
177+
178+
function test_html_no_button() {
179+
local tfile="${tftmp_file}_html_no_button";
180+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
181+
local pex_=("${exp[@]}" "$tfile" --no-button)
182+
183+
assert_exit_code "0" "$("${ex_[@]}")";
184+
assert_is_file "$tfile";
185+
186+
local pexout="$("${pex_[@]}")";
187+
assert_exit_code "0" "$?";
188+
assert_not_contains "<button" "$pexout";
189+
190+
rm "$tfile";
191+
}
192+
193+
function test_html_no_js() {
194+
local tfile="${tftmp_file}_html_no_js";
195+
local ex_=("${ex[@]}" --output "$tfile" --opt "${sopt[*]}" --flag "${sflg[*]}" --nested "${snst[*]}" --pos "${spos[*]}")
196+
local pex_=("${exp[@]}" "$tfile" --no-js)
197+
198+
assert_exit_code "0" "$("${ex_[@]}")";
199+
assert_is_file "$tfile";
200+
201+
local pexout="$("${pex_[@]}")";
202+
assert_exit_code "0" "$?";
203+
assert_not_contains "<script" "$pexout";
204+
100205
rm "$tfile";
101206
}

0 commit comments

Comments
 (0)