MCPcopy Create free account
hub / github.com/google/go-github / Test_ParseForms

Function Test_ParseForms

scrape/forms_test.go:19–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func Test_ParseForms(t *testing.T) {
20 t.Parallel()
21 tests := []struct {
22 description string
23 html string
24 forms []*htmlForm
25 }{
26 {"no forms", `<html></html>`, nil},
27 {"empty form", `<html><form></form></html>`, []*htmlForm{{Values: url.Values{}}}},
28 {
29 "single form with one value",
30 `<html><form action="a" method="m"><input name="n1" value="v1"></form></html>`,
31 []*htmlForm{{Action: "a", Method: "m", Values: url.Values{"n1": {"v1"}}}},
32 },
33 {
34 "two forms",
35 `<html>
36 <form action="a1" method="m1"><input name="n1" value="v1"></form>
37 <form action="a2" method="m2"><input name="n2" value="v2"></form>
38 </html>`,
39 []*htmlForm{
40 {Action: "a1", Method: "m1", Values: url.Values{"n1": {"v1"}}},
41 {Action: "a2", Method: "m2", Values: url.Values{"n2": {"v2"}}},
42 },
43 },
44 {
45 "form with radio buttons (none checked)",
46 `<html><form>
47 <input type="radio" name="n1" value="v1">
48 <input type="radio" name="n1" value="v2">
49 <input type="radio" name="n1" value="v3">
50 </form></html>`,
51 []*htmlForm{{Values: url.Values{}}},
52 },
53 {
54 "form with radio buttons",
55 `<html><form>
56 <input type="radio" name="n1" value="v1">
57 <input type="radio" name="n1" value="v2">
58 <input type="radio" name="n1" value="v3" checked>
59 </form></html>`,
60 []*htmlForm{{Values: url.Values{"n1": {"v3"}}}},
61 },
62 {
63 "form with checkboxes",
64 `<html><form>
65 <input type="checkbox" name="n1" value="v1" checked>
66 <input type="checkbox" name="n2" value="v2">
67 <input type="checkbox" name="n3" value="v3" checked>
68 </form></html>`,
69 []*htmlForm{{Values: url.Values{"n1": {"v1"}, "n3": {"v3"}}}},
70 },
71 {
72 "single form with textarea",
73 `<html><form><textarea name="n1">v1</textarea></form></html>`,
74 []*htmlForm{{Values: url.Values{"n1": {"v1"}}}},
75 },
76 }

Callers

nothing calls this directly

Calls 3

parseFormsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…