aboutsummaryrefslogtreecommitdiff
path: root/node_modules/domutils/tests
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/domutils/tests')
-rw-r--r--node_modules/domutils/tests/00-runtests.js64
-rw-r--r--node_modules/domutils/tests/02-dom_utils.js15
-rw-r--r--node_modules/domutils/tests/DomUtils/01-by_id.js56
-rw-r--r--node_modules/domutils/tests/DomUtils/02-by_tagname.js23
-rw-r--r--node_modules/domutils/tests/DomUtils/03-by_type.js23
-rw-r--r--node_modules/domutils/tests/DomUtils/04-outer_html.js10
-rw-r--r--node_modules/domutils/tests/DomUtils/05-inner_html.js10
7 files changed, 0 insertions, 201 deletions
diff --git a/node_modules/domutils/tests/00-runtests.js b/node_modules/domutils/tests/00-runtests.js
deleted file mode 100644
index cf7a3b7f8..000000000
--- a/node_modules/domutils/tests/00-runtests.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var fs = require("fs"),
- assert = require("assert");
-
-var runCount = 0,
- testCount = 0;
-
-function compare(expected, result){
- if(typeof expected !== typeof result){
- throw Error("types didn't match");
- }
- if(typeof expected !== "object" || expected === null){
- if(expected !== result){
- throw Error("result doesn't equal expected");
- }
- return;
- }
-
- for(var prop in expected){
- if(!(prop in result)) throw Error("result didn't contain property " + prop);
- compare(expected[prop], result[prop]);
- }
-}
-
-function runTests(test){
- //read files, load them, run them
- fs.readdirSync(__dirname + test.dir
- ).map(function(file){
- if(file[0] === ".") return false;
- if(file.substr(-5) === ".json") return JSON.parse(
- fs.readFileSync(__dirname + test.dir + file)
- );
- return require(__dirname + test.dir + file);
- }).forEach(function(file){
- if(!file) return;
- var second = false;
-
- runCount++;
-
- console.log("Testing:", file.name);
-
- test.test(file, function(err, dom){
- assert.ifError(err);
- compare(file.expected, dom);
-
- if(second){
- runCount--;
- testCount++;
- }
- else second = true;
- });
- });
- console.log("->", test.dir.slice(1, -1), "started");
-}
-
-//run all tests
-[
- "./02-dom_utils.js"
-].map(require).forEach(runTests);
-
-//log the results
-(function check(){
- if(runCount !== 0) return process.nextTick(check);
- console.log("Total tests:", testCount);
-}()); \ No newline at end of file
diff --git a/node_modules/domutils/tests/02-dom_utils.js b/node_modules/domutils/tests/02-dom_utils.js
deleted file mode 100644
index 9a28b891b..000000000
--- a/node_modules/domutils/tests/02-dom_utils.js
+++ /dev/null
@@ -1,15 +0,0 @@
-//generate a dom
-var handler = new (require("domhandler"))();
-
-(new (require("htmlparser2").Parser)(handler)).parseComplete(
- Array(21).join("<?xml><tag1 id='asdf'> <script>text</script> <!-- comment --> <tag2> text </tag1>")
-);
-
-var dom = handler.dom;
-
-exports.dir = "/DomUtils/";
-
-exports.test = function(test, cb){
- cb(null, test.getElements(dom));
- cb(null, test.getByFunction(dom));
-}; \ No newline at end of file
diff --git a/node_modules/domutils/tests/DomUtils/01-by_id.js b/node_modules/domutils/tests/DomUtils/01-by_id.js
deleted file mode 100644
index a5f02df24..000000000
--- a/node_modules/domutils/tests/DomUtils/01-by_id.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var DomUtils = require("../..");
-
-exports.name = "Get element by id";
-exports.getElements = function(dom){
- return DomUtils.getElements({id:"asdf"}, dom, true, 1)[0];
-};
-exports.getByFunction = function(dom){
- return DomUtils.getElementById("asdf", dom, true);
-};
-exports.expected = {
- "type": "tag",
- "name": "tag1",
- "attribs": {
- "id": "asdf"
- },
- "children": [
- {
- "data": " ",
- "type": "text"
- },
- {
- "type": "script",
- "name": "script",
- "attribs": {},
- "children": [
- {
- "data": "text",
- "type": "text"
- }
- ]
- },
- {
- "data": " ",
- "type": "text"
- },
- {
- "data": " comment ",
- "type": "comment"
- },
- {
- "data": " ",
- "type": "text"
- },
- {
- "type": "tag",
- "name": "tag2",
- "attribs": {},
- "children": [
- {
- "data": " text ",
- "type": "text"
- }
- ]
- }
- ]
-}; \ No newline at end of file
diff --git a/node_modules/domutils/tests/DomUtils/02-by_tagname.js b/node_modules/domutils/tests/DomUtils/02-by_tagname.js
deleted file mode 100644
index 125357c41..000000000
--- a/node_modules/domutils/tests/DomUtils/02-by_tagname.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var DomUtils = require("../..");
-
-exports.name = "Get elements by tagName";
-exports.getElements = function(dom){
- return DomUtils.getElements({tag_name:"tag2"}, dom, true);
-};
-exports.getByFunction = function(dom){
- return DomUtils.getElementsByTagName("tag2", dom, true);
-};
-exports.expected = [];
-for(var i = 0; i < 20; i++) exports.expected.push(
- {
- "type": "tag",
- "name": "tag2",
- "attribs": {},
- "children": [
- {
- "data": " text ",
- "type": "text"
- }
- ]
- }
-); \ No newline at end of file
diff --git a/node_modules/domutils/tests/DomUtils/03-by_type.js b/node_modules/domutils/tests/DomUtils/03-by_type.js
deleted file mode 100644
index 43bd66791..000000000
--- a/node_modules/domutils/tests/DomUtils/03-by_type.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var DomUtils = require("../..");
-
-exports.name = "Get elements by type";
-exports.getElements = function(dom){
- return DomUtils.getElements({tag_type:"script"}, dom, true);
-};
-exports.getByFunction = function(dom){
- return DomUtils.getElementsByTagType("script", dom, true);
-};
-exports.expected = [];
-for(var i = 0; i < 20; i++) exports.expected.push(
- {
- "type": "script",
- "name": "script",
- "attribs": {},
- "children": [
- {
- "data": "text",
- "type": "text"
- }
- ]
- }
-); \ No newline at end of file
diff --git a/node_modules/domutils/tests/DomUtils/04-outer_html.js b/node_modules/domutils/tests/DomUtils/04-outer_html.js
deleted file mode 100644
index 57aae971f..000000000
--- a/node_modules/domutils/tests/DomUtils/04-outer_html.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var DomUtils = require("../..");
-
-exports.name = "Get outer HTML";
-exports.getElements = function(dom){
- return '<tag1 id="asdf"> <script>text</script> <!-- comment --> <tag2> text </tag2></tag1>';
-};
-exports.getByFunction = function(dom){
- return DomUtils.getOuterHTML(DomUtils.getElementById("asdf", dom, true));
-};
-exports.expected = '<tag1 id="asdf"> <script>text</script> <!-- comment --> <tag2> text </tag2></tag1>';
diff --git a/node_modules/domutils/tests/DomUtils/05-inner_html.js b/node_modules/domutils/tests/DomUtils/05-inner_html.js
deleted file mode 100644
index 36a266163..000000000
--- a/node_modules/domutils/tests/DomUtils/05-inner_html.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var DomUtils = require("../..");
-
-exports.name = "Get inner HTML";
-exports.getElements = function(dom){
- return ' <script>text</script> <!-- comment --> <tag2> text </tag2>';
-};
-exports.getByFunction = function(dom){
- return DomUtils.getInnerHTML(DomUtils.getElementById("asdf", dom, true));
-};
-exports.expected = ' <script>text</script> <!-- comment --> <tag2> text </tag2>';