added old data
This commit is contained in:
57
project3/node_modules/domhandler/test/cases/01-basic.json
generated
vendored
Normal file
57
project3/node_modules/domhandler/test/cases/01-basic.json
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "Basic test",
|
||||
"options": {},
|
||||
"html": "<!DOCTYPE html><html><title>The Title</title><body>Hello world</body></html>",
|
||||
"expected": [
|
||||
{
|
||||
"name": "!doctype",
|
||||
"data": "!DOCTYPE html",
|
||||
"type": "directive"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "html",
|
||||
"attribs": {},
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "title",
|
||||
"attribs": {},
|
||||
"parent": {
|
||||
"type": "tag",
|
||||
"name": "html",
|
||||
"attribs": {}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "The Title",
|
||||
"type": "text",
|
||||
"parent": {
|
||||
"type": "tag",
|
||||
"name": "title",
|
||||
"attribs": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "body",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "Hello world",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"prev": {
|
||||
"type": "tag",
|
||||
"name": "title",
|
||||
"attribs": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
21
project3/node_modules/domhandler/test/cases/02-single_tag_1.json
generated
vendored
Normal file
21
project3/node_modules/domhandler/test/cases/02-single_tag_1.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Single Tag 1",
|
||||
"options": {},
|
||||
"html": "<br>text</br>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": "text",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
}
|
||||
]
|
||||
}
|
21
project3/node_modules/domhandler/test/cases/03-single_tag_2.json
generated
vendored
Normal file
21
project3/node_modules/domhandler/test/cases/03-single_tag_2.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Single Tag 2",
|
||||
"options": {},
|
||||
"html": "<br>text<br>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": "text",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
}
|
||||
]
|
||||
}
|
27
project3/node_modules/domhandler/test/cases/04-unescaped_in_script.json
generated
vendored
Normal file
27
project3/node_modules/domhandler/test/cases/04-unescaped_in_script.json
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "Unescaped chars in script",
|
||||
"options": {},
|
||||
"html": "<head><script language=\"Javascript\">var foo = \"<bar>\"; alert(2 > foo); var baz = 10 << 2; var zip = 10 >> 1; var yap = \"<<>>>><<\";</script></head>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "head",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"type": "script",
|
||||
"name": "script",
|
||||
"attribs": {
|
||||
"language": "Javascript"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "var foo = \"<bar>\"; alert(2 > foo); var baz = 10 << 2; var zip = 10 >> 1; var yap = \"<<>>>><<\";",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
18
project3/node_modules/domhandler/test/cases/05-tags_in_comment.json
generated
vendored
Normal file
18
project3/node_modules/domhandler/test/cases/05-tags_in_comment.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "Special char in comment",
|
||||
"options": {},
|
||||
"html": "<head><!-- commented out tags <title>Test</title>--></head>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "head",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": " commented out tags <title>Test</title>",
|
||||
"type": "comment"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
18
project3/node_modules/domhandler/test/cases/06-comment_in_script.json
generated
vendored
Normal file
18
project3/node_modules/domhandler/test/cases/06-comment_in_script.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "Script source in comment",
|
||||
"options": {},
|
||||
"html": "<script><!--var foo = 1;--></script>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "script",
|
||||
"name": "script",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "<!--var foo = 1;-->",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
20
project3/node_modules/domhandler/test/cases/07-unescaped_in_style.json
generated
vendored
Normal file
20
project3/node_modules/domhandler/test/cases/07-unescaped_in_style.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Unescaped chars in style",
|
||||
"options": {},
|
||||
"html": "<style type=\"text/css\">\n body > p\n\t{ font-weight: bold; }</style>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "style",
|
||||
"name": "style",
|
||||
"attribs": {
|
||||
"type": "text/css"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "\n body > p\n\t{ font-weight: bold; }",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
20
project3/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json
generated
vendored
Normal file
20
project3/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Extra spaces in tag",
|
||||
"options": {},
|
||||
"html": "<font\t\n size='14' \n>the text</\t\nfont\t \n>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "font",
|
||||
"attribs": {
|
||||
"size": "14"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
20
project3/node_modules/domhandler/test/cases/09-unquoted_attrib.json
generated
vendored
Normal file
20
project3/node_modules/domhandler/test/cases/09-unquoted_attrib.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Unquoted attributes",
|
||||
"options": {},
|
||||
"html": "<font size= 14>the text</font>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "font",
|
||||
"attribs": {
|
||||
"size": "14"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
15
project3/node_modules/domhandler/test/cases/10-singular_attribute.json
generated
vendored
Normal file
15
project3/node_modules/domhandler/test/cases/10-singular_attribute.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Singular attribute",
|
||||
"options": {},
|
||||
"html": "<option value='foo' selected>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "option",
|
||||
"attribs": {
|
||||
"value": "foo",
|
||||
"selected": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
40
project3/node_modules/domhandler/test/cases/11-text_outside_tags.json
generated
vendored
Normal file
40
project3/node_modules/domhandler/test/cases/11-text_outside_tags.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "Text outside tags",
|
||||
"options": {},
|
||||
"html": "Line one\n<br>\nline two",
|
||||
"expected": [
|
||||
{
|
||||
"data": "Line one\n",
|
||||
"type": "text",
|
||||
"prev": null,
|
||||
"next": {
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {},
|
||||
"prev": {
|
||||
"data": "Line one\n",
|
||||
"type": "text"
|
||||
},
|
||||
"next": {
|
||||
"data": "\nline two",
|
||||
"type": "text"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "\nline two",
|
||||
"type": "text",
|
||||
"prev": {
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
"next": null
|
||||
}
|
||||
]
|
||||
}
|
11
project3/node_modules/domhandler/test/cases/12-text_only.json
generated
vendored
Normal file
11
project3/node_modules/domhandler/test/cases/12-text_only.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Only text",
|
||||
"options": {},
|
||||
"html": "this is the text",
|
||||
"expected": [
|
||||
{
|
||||
"data": "this is the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
19
project3/node_modules/domhandler/test/cases/13-comment_in_text.json
generated
vendored
Normal file
19
project3/node_modules/domhandler/test/cases/13-comment_in_text.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Comment within text",
|
||||
"options": {},
|
||||
"html": "this is <!-- the comment --> the text",
|
||||
"expected": [
|
||||
{
|
||||
"data": "this is ",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"data": " the comment ",
|
||||
"type": "comment"
|
||||
},
|
||||
{
|
||||
"data": " the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
18
project3/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json
generated
vendored
Normal file
18
project3/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "Comment within text within script",
|
||||
"options": {},
|
||||
"html": "<script>this is <!-- the comment --> the text</script>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "script",
|
||||
"name": "script",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "this is <!-- the comment --> the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
22
project3/node_modules/domhandler/test/cases/15-non-verbose.json
generated
vendored
Normal file
22
project3/node_modules/domhandler/test/cases/15-non-verbose.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Option 'verbose' set to 'false'",
|
||||
"options": {
|
||||
"verbose": false
|
||||
},
|
||||
"html": "<font\t\n size='14' \n>the text</\t\nfont\t \n>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "font",
|
||||
"attribs": {
|
||||
"size": "14"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "the text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
47
project3/node_modules/domhandler/test/cases/16-normalize_whitespace.json
generated
vendored
Normal file
47
project3/node_modules/domhandler/test/cases/16-normalize_whitespace.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "Normalize whitespace",
|
||||
"options": {
|
||||
"normalizeWhitespace": true
|
||||
},
|
||||
"html": "Line one\n<br>\t \r\n\f <br>\nline two<font><br> x </font>",
|
||||
"expected": [
|
||||
{
|
||||
"data": "Line one ",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": " ",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": " line two",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "font",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "br",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": " x ",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
18
project3/node_modules/domhandler/test/cases/17-xml_namespace.json
generated
vendored
Normal file
18
project3/node_modules/domhandler/test/cases/17-xml_namespace.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "XML Namespace",
|
||||
"options": {},
|
||||
"html": "<ns:tag>text</ns:tag>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "ns:tag",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
16
project3/node_modules/domhandler/test/cases/18-enforce_empty_tags.json
generated
vendored
Normal file
16
project3/node_modules/domhandler/test/cases/18-enforce_empty_tags.json
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Enforce empty tags",
|
||||
"options": {},
|
||||
"html": "<link>text</link>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "link",
|
||||
"attribs": {}
|
||||
},
|
||||
{
|
||||
"data": "text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
20
project3/node_modules/domhandler/test/cases/19-ignore_empty_tags.json
generated
vendored
Normal file
20
project3/node_modules/domhandler/test/cases/19-ignore_empty_tags.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Ignore empty tags (xml mode)",
|
||||
"options": {
|
||||
"xmlMode": true
|
||||
},
|
||||
"html": "<link>text</link>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "link",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
20
project3/node_modules/domhandler/test/cases/20-template_script_tags.json
generated
vendored
Normal file
20
project3/node_modules/domhandler/test/cases/20-template_script_tags.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Template script tags",
|
||||
"options": {},
|
||||
"html": "<script type=\"text/template\"><h1>Heading1</h1></script>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "script",
|
||||
"name": "script",
|
||||
"attribs": {
|
||||
"type": "text/template"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"data": "<h1>Heading1</h1>",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
15
project3/node_modules/domhandler/test/cases/21-conditional_comments.json
generated
vendored
Normal file
15
project3/node_modules/domhandler/test/cases/21-conditional_comments.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Conditional comments",
|
||||
"options": {},
|
||||
"html": "<!--[if lt IE 7]> <html class='no-js ie6 oldie' lang='en'> <![endif]--><!--[if lt IE 7]> <html class='no-js ie6 oldie' lang='en'> <![endif]-->",
|
||||
"expected": [
|
||||
{
|
||||
"data": "[if lt IE 7]> <html class='no-js ie6 oldie' lang='en'> <![endif]",
|
||||
"type": "comment"
|
||||
},
|
||||
{
|
||||
"data": "[if lt IE 7]> <html class='no-js ie6 oldie' lang='en'> <![endif]",
|
||||
"type": "comment"
|
||||
}
|
||||
]
|
||||
}
|
41
project3/node_modules/domhandler/test/cases/22-lowercase_tags.json
generated
vendored
Normal file
41
project3/node_modules/domhandler/test/cases/22-lowercase_tags.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "lowercase tags",
|
||||
"options": {},
|
||||
"html": "<!DOCTYPE html><HTML><TITLE>The Title</title><BODY>Hello world</body></html>",
|
||||
"expected": [
|
||||
{
|
||||
"name": "!doctype",
|
||||
"data": "!DOCTYPE html",
|
||||
"type": "directive"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "html",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "title",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "The Title",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"name": "body",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"data": "Hello world",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
131
project3/node_modules/domhandler/test/cases/23-dom-lvl1.json
generated
vendored
Normal file
131
project3/node_modules/domhandler/test/cases/23-dom-lvl1.json
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
{
|
||||
"name": "DOM level 1",
|
||||
"options": { "withDomLvl1": true },
|
||||
"html": "<div>some stray text<h1>Hello, world.</h1><!-- comment node -->more stray text</div>",
|
||||
"expected": [
|
||||
{
|
||||
"type": "tag",
|
||||
"nodeType": 1,
|
||||
"name": "div",
|
||||
"tagName": "div",
|
||||
"attribs": {},
|
||||
"nodeValue": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "some stray text",
|
||||
"nodeValue": "some stray text",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"nodeType": 1,
|
||||
"name": "h1",
|
||||
"tagName": "h1",
|
||||
"nodeValue": null,
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "Hello, world.",
|
||||
"nodeValue": "Hello, world.",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
}
|
||||
],
|
||||
"firstChild": {
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "Hello, world.",
|
||||
"nodeValue": "Hello, world.",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
},
|
||||
"lastChild": {
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "Hello, world.",
|
||||
"nodeValue": "Hello, world.",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"nodeType": 8,
|
||||
"tagName": null,
|
||||
"data": " comment node ",
|
||||
"nodeValue": " comment node ",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null,
|
||||
"prev": {
|
||||
"type": "tag",
|
||||
"name": "h1",
|
||||
"nodeValue": null,
|
||||
"attribs": {}
|
||||
},
|
||||
"previousSibling": {
|
||||
"type": "tag",
|
||||
"name": "h1",
|
||||
"nodeValue": null,
|
||||
"attribs": {}
|
||||
},
|
||||
"next": {
|
||||
"type": "text",
|
||||
"tagName": null,
|
||||
"data": "more stray text"
|
||||
},
|
||||
"nextSibling": {
|
||||
"type": "text",
|
||||
"tagName": null,
|
||||
"data": "more stray text"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "more stray text",
|
||||
"nodeValue": "more stray text",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null,
|
||||
"next": null,
|
||||
"nextSibling": null
|
||||
}
|
||||
],
|
||||
"firstChild": {
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "some stray text",
|
||||
"nodeValue": "some stray text",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
},
|
||||
"lastChild": {
|
||||
"type": "text",
|
||||
"nodeType": 3,
|
||||
"tagName": null,
|
||||
"data": "more stray text",
|
||||
"nodeValue": "more stray text",
|
||||
"childNodes": null,
|
||||
"firstChild": null,
|
||||
"lastChild": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
85
project3/node_modules/domhandler/test/cases/24-with-start-indices.json
generated
vendored
Normal file
85
project3/node_modules/domhandler/test/cases/24-with-start-indices.json
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"name": "withStartIndices adds correct startIndex properties",
|
||||
"options": {"withStartIndices": true},
|
||||
"streaming": false,
|
||||
"html": "<!DOCTYPE html> <html> <title>The Title</title> <body class='foo'>Hello world <p></p></body> <!-- the comment --> </html> ",
|
||||
"expected": [
|
||||
{
|
||||
"startIndex": 0,
|
||||
"name": "!doctype",
|
||||
"data": "!DOCTYPE html",
|
||||
"type": "directive"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"data": " "
|
||||
},
|
||||
{
|
||||
"startIndex": 16,
|
||||
"type": "tag",
|
||||
"name": "html",
|
||||
"attribs": {},
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"startIndex": 22,
|
||||
"type": "text",
|
||||
"data": " "
|
||||
},
|
||||
{
|
||||
"startIndex": 23,
|
||||
"type": "tag",
|
||||
"name": "title",
|
||||
"attribs": {},
|
||||
"children": [
|
||||
{
|
||||
"startIndex": 30,
|
||||
"data": "The Title",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startIndex": 47,
|
||||
"type": "text",
|
||||
"data": " "
|
||||
},
|
||||
{
|
||||
"startIndex": 48,
|
||||
"type": "tag",
|
||||
"name": "body",
|
||||
"attribs": {"class": "foo"},
|
||||
"children": [
|
||||
{
|
||||
"startIndex": 66,
|
||||
"data": "Hello world ",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"startIndex": 78,
|
||||
"type": "tag",
|
||||
"name": "p",
|
||||
"attribs": {},
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startIndex": 92,
|
||||
"type": "text",
|
||||
"data": " "
|
||||
},
|
||||
{
|
||||
"startIndex": 93,
|
||||
"type": "comment",
|
||||
"data": " the comment "
|
||||
},
|
||||
{
|
||||
"startIndex": 113,
|
||||
"type": "text",
|
||||
"data": " "
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
60
project3/node_modules/domhandler/test/tests.js
generated
vendored
Normal file
60
project3/node_modules/domhandler/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
assert = require("assert"),
|
||||
util = require("util"),
|
||||
Parser = require("htmlparser2").Parser,
|
||||
Handler = require("../");
|
||||
|
||||
var basePath = path.resolve(__dirname, "cases"),
|
||||
inspectOpts = { showHidden: true, depth: null };
|
||||
|
||||
fs
|
||||
.readdirSync(basePath)
|
||||
.filter(RegExp.prototype.test, /\.json$/) //only allow .json files
|
||||
.map(function(name){
|
||||
return path.resolve(basePath, name);
|
||||
})
|
||||
.map(require)
|
||||
.forEach(function(test){
|
||||
it(test.name, function(){
|
||||
var expected = test.expected;
|
||||
|
||||
var handler = new Handler(function(err, actual){
|
||||
assert.ifError(err);
|
||||
try {
|
||||
compare(expected, actual);
|
||||
} catch(e){
|
||||
e.expected = util.inspect(expected, inspectOpts);
|
||||
e.actual = util.inspect(actual, inspectOpts);
|
||||
throw e;
|
||||
}
|
||||
}, test.options);
|
||||
|
||||
var data = test.html;
|
||||
|
||||
var parser = new Parser(handler, test.options);
|
||||
|
||||
//first, try to run the test via chunks
|
||||
if (test.streaming || test.streaming === undefined){
|
||||
for(var i = 0; i < data.length; i++){
|
||||
parser.write(data.charAt(i));
|
||||
}
|
||||
parser.done();
|
||||
}
|
||||
|
||||
//then parse everything
|
||||
parser.parseComplete(data);
|
||||
});
|
||||
});
|
||||
|
||||
function compare(expected, result){
|
||||
assert.equal(typeof expected, typeof result, "types didn't match");
|
||||
if(typeof expected !== "object" || expected === null){
|
||||
assert.strictEqual(expected, result, "result doesn't equal expected");
|
||||
} else {
|
||||
for(var prop in expected){
|
||||
assert.ok(prop in result, "result didn't contain property " + prop);
|
||||
compare(expected[prop], result[prop]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user