@@ -4,84 +4,117 @@ defmodule MeeseeksHtml5everTest do
44
55 test "parse div" do
66 html = "<special:div>Hello, World!</special:div>"
7- ret = { :ok ,
8- % { __struct__: :"Elixir.Meeseeks.Document" ,
9- id_counter: 5 ,
10- nodes: % {
11- 1 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
12- attributes: [ ] ,
13- children: [ 2 , 3 ] ,
14- id: 1 ,
15- namespace: "" ,
16- parent: nil ,
17- tag: "html" } ,
18- 2 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
19- attributes: [ ] ,
20- children: [ ] ,
21- id: 2 ,
22- namespace: "" ,
23- parent: 1 ,
24- tag: "head" } ,
25- 3 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
26- attributes: [ ] ,
27- children: [ 4 ] ,
28- id: 3 ,
29- namespace: "" ,
30- parent: 1 ,
31- tag: "body" } ,
32- 4 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
33- attributes: [ ] ,
34- children: [ 5 ] ,
35- id: 4 ,
36- namespace: "special" ,
37- parent: 3 ,
38- tag: "div" } ,
39- 5 => % { __struct__: :"Elixir.Meeseeks.Document.Text" ,
40- content: "Hello, World!" ,
41- id: 5 ,
42- parent: 4 } } ,
43- roots: [ 1 ] } }
7+
8+ ret =
9+ { :ok ,
10+ % {
11+ __struct__: :"Elixir.Meeseeks.Document" ,
12+ id_counter: 5 ,
13+ nodes: % {
14+ 1 => % {
15+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
16+ attributes: [ ] ,
17+ children: [ 2 , 3 ] ,
18+ id: 1 ,
19+ namespace: "" ,
20+ parent: nil ,
21+ tag: "html"
22+ } ,
23+ 2 => % {
24+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
25+ attributes: [ ] ,
26+ children: [ ] ,
27+ id: 2 ,
28+ namespace: "" ,
29+ parent: 1 ,
30+ tag: "head"
31+ } ,
32+ 3 => % {
33+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
34+ attributes: [ ] ,
35+ children: [ 4 ] ,
36+ id: 3 ,
37+ namespace: "" ,
38+ parent: 1 ,
39+ tag: "body"
40+ } ,
41+ 4 => % {
42+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
43+ attributes: [ ] ,
44+ children: [ 5 ] ,
45+ id: 4 ,
46+ namespace: "special" ,
47+ parent: 3 ,
48+ tag: "div"
49+ } ,
50+ 5 => % {
51+ __struct__: :"Elixir.Meeseeks.Document.Text" ,
52+ content: "Hello, World!" ,
53+ id: 5 ,
54+ parent: 4
55+ }
56+ } ,
57+ roots: [ 1 ]
58+ } }
59+
4460 assert MeeseeksHtml5ever . parse_html ( html ) == ret
4561 end
4662
4763 test "parse simple document" do
4864 html = "<html><head></head><body><div>Hello, World!</div></body></html>"
49- ret = { :ok ,
50- % { __struct__: :"Elixir.Meeseeks.Document" ,
51- id_counter: 5 ,
52- nodes: % {
53- 1 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
54- attributes: [ ] ,
55- children: [ 2 , 3 ] ,
56- id: 1 ,
57- namespace: "" ,
58- parent: nil ,
59- tag: "html" } ,
60- 2 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
61- attributes: [ ] ,
62- children: [ ] ,
63- id: 2 ,
64- namespace: "" ,
65- parent: 1 ,
66- tag: "head" } ,
67- 3 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
68- attributes: [ ] ,
69- children: [ 4 ] ,
70- id: 3 ,
71- namespace: "" ,
72- parent: 1 ,
73- tag: "body" } ,
74- 4 => % { __struct__: :"Elixir.Meeseeks.Document.Element" ,
75- attributes: [ ] ,
76- children: [ 5 ] ,
77- id: 4 ,
78- namespace: "" ,
79- parent: 3 ,
80- tag: "div" } ,
81- 5 => % { __struct__: :"Elixir.Meeseeks.Document.Text" ,
82- content: "Hello, World!" ,
83- id: 5 , parent: 4 } } ,
84- roots: [ 1 ] } }
65+
66+ ret =
67+ { :ok ,
68+ % {
69+ __struct__: :"Elixir.Meeseeks.Document" ,
70+ id_counter: 5 ,
71+ nodes: % {
72+ 1 => % {
73+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
74+ attributes: [ ] ,
75+ children: [ 2 , 3 ] ,
76+ id: 1 ,
77+ namespace: "" ,
78+ parent: nil ,
79+ tag: "html"
80+ } ,
81+ 2 => % {
82+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
83+ attributes: [ ] ,
84+ children: [ ] ,
85+ id: 2 ,
86+ namespace: "" ,
87+ parent: 1 ,
88+ tag: "head"
89+ } ,
90+ 3 => % {
91+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
92+ attributes: [ ] ,
93+ children: [ 4 ] ,
94+ id: 3 ,
95+ namespace: "" ,
96+ parent: 1 ,
97+ tag: "body"
98+ } ,
99+ 4 => % {
100+ __struct__: :"Elixir.Meeseeks.Document.Element" ,
101+ attributes: [ ] ,
102+ children: [ 5 ] ,
103+ id: 4 ,
104+ namespace: "" ,
105+ parent: 3 ,
106+ tag: "div"
107+ } ,
108+ 5 => % {
109+ __struct__: :"Elixir.Meeseeks.Document.Text" ,
110+ content: "Hello, World!" ,
111+ id: 5 ,
112+ parent: 4
113+ }
114+ } ,
115+ roots: [ 1 ]
116+ } }
117+
85118 assert MeeseeksHtml5ever . parse_html ( html ) == ret
86119 end
87120
@@ -107,22 +140,27 @@ defmodule MeeseeksHtml5everTest do
107140
108141 test "parse xml" do
109142 xml = "<special:greeting>Hello, World!</special:greeting>"
110- ret = { :ok ,
111- % { __struct__: Meeseeks.Document ,
112- id_counter: 2 ,
113- nodes: % {
114- 1 => % { __struct__: Meeseeks.Document.Element ,
115- attributes: [ ] ,
116- children: [ 2 ] ,
117- id: 1 ,
118- namespace: "special" ,
119- parent: nil ,
120- tag: "greeting" } ,
121- 2 => % { __struct__: Meeseeks.Document.Text ,
122- content: "Hello, World!" ,
123- id: 2 ,
124- parent: 1 } } ,
125- roots: [ 1 ] } }
143+
144+ ret =
145+ { :ok ,
146+ % {
147+ __struct__: Meeseeks.Document ,
148+ id_counter: 2 ,
149+ nodes: % {
150+ 1 => % {
151+ __struct__: Meeseeks.Document.Element ,
152+ attributes: [ ] ,
153+ children: [ 2 ] ,
154+ id: 1 ,
155+ namespace: "special" ,
156+ parent: nil ,
157+ tag: "greeting"
158+ } ,
159+ 2 => % { __struct__: Meeseeks.Document.Text , content: "Hello, World!" , id: 2 , parent: 1 }
160+ } ,
161+ roots: [ 1 ]
162+ } }
163+
126164 assert MeeseeksHtml5ever . parse_xml ( xml ) == ret
127165 end
128166end
0 commit comments