html-snapshots 0.18.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +4 -5
- package/.github/workflows/verify.yml +2 -2
- package/HISTORY.md +42 -0
- package/README.md +109 -256
- package/examples/README.md +149 -0
- package/examples/custom/myFilter.js +2 -2
- package/examples/custom/package-lock.json +2021 -5
- package/examples/custom/package.json +1 -1
- package/examples/custom/snapshot.js +8 -10
- package/examples/debug-phantomjs/package-lock.json +6 -6
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +13 -14
- package/examples/debug-puppeteer/README.md +18 -0
- package/examples/debug-puppeteer/package-lock.json +2804 -0
- package/examples/debug-puppeteer/package.json +12 -0
- package/examples/debug-puppeteer/snapshot.js +30 -0
- package/examples/html5rocks/package-lock.json +1306 -5
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +14 -23
- package/examples/process-limit/package-lock.json +1306 -5
- package/examples/process-limit/package.json +1 -1
- package/examples/process-limit/snapshot.js +8 -10
- package/examples/simple-promise/package-lock.json +1306 -5
- package/examples/simple-promise/package.json +1 -1
- package/examples/simple-promise/snapshot.js +6 -8
- package/examples/sitemap-index/package-lock.json +1306 -5
- package/examples/sitemap-index/package.json +1 -1
- package/examples/sitemap-index/snapshot.js +6 -6
- package/examples/utils/index.js +2 -4
- package/examples/verbose/package-lock.json +1306 -5
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +12 -14
- package/lib/async/index.js +0 -1
- package/lib/common/index.js +1 -1
- package/lib/common/sitemap/index.js +16 -0
- package/lib/common/sitemap/sitemap-collection.js +94 -0
- package/lib/common/sitemap/sitemap-index.js +68 -0
- package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
- package/lib/html-snapshots.js +87 -5
- package/lib/input-generators/_base.js +7 -1
- package/lib/input-generators/array.js +0 -1
- package/lib/input-generators/robots.js +98 -58
- package/lib/input-generators/sitemap-index.js +3 -124
- package/lib/input-generators/sitemap.js +3 -7
- package/lib/input-generators/textfile.js +2 -6
- package/lib/puppeteer/index.js +98 -0
- package/lib/puppeteer/removeScripts.js +8 -0
- package/package.json +9 -4
- package/test/helpers/options.js +4 -2
- package/test/mocha/browsers/puppeteer.js +106 -0
- package/test/mocha/browsers/server/index.html +9 -0
- package/test/mocha/browsers/test.js +11 -0
- package/test/mocha/html-snapshots/basics.js +60 -47
- package/test/mocha/html-snapshots/phantomjs-options.js +54 -60
- package/test/mocha/html-snapshots/process-limit.js +126 -120
- package/test/mocha/html-snapshots/puppeteer.js +47 -0
- package/test/mocha/html-snapshots/robots.js +156 -121
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
- package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
- package/test/mocha/html-snapshots/sitemap-index.js +100 -90
- package/test/mocha/html-snapshots/sitemap.js +75 -31
- package/test/mocha/html-snapshots/snapshot-scripts.js +150 -145
- package/test/mocha/html-snapshots/test.js +23 -14
- package/test/mocha/html-snapshots/test_robots.txt +0 -2
- package/test/mocha/html-snapshots/use-jquery.js +65 -64
- package/test/mocha/html-snapshots/utils.js +29 -30
- package/test/mocha/input-generators/server/test_robots.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
- package/test/mocha/input-generators/sitemap-index.js +65 -9
- package/test/mocha/input-generators/test.js +276 -280
- package/test/mocha/input-generators/test_robots.txt +0 -2
- package/test/mocha/input-generators/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
- package/lib/common/node.js +0 -26
- package/test/mocha/common/node.js +0 -100
|
@@ -4,48 +4,61 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global it */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const assert = require("assert");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const _ = require("lodash");
|
|
10
|
+
const utils = require("./utils");
|
|
11
|
+
const optHelp = require("../../helpers/options");
|
|
12
|
+
const ss = require("../../../lib/html-snapshots");
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
timeout,
|
|
16
|
+
outputDir,
|
|
17
|
+
cleanup,
|
|
18
|
+
cleanupError,
|
|
19
|
+
unexpectedError,
|
|
20
|
+
unexpectedSuccess,
|
|
21
|
+
checkActualFiles
|
|
22
|
+
} = utils;
|
|
23
|
+
|
|
24
|
+
const useJQOutputDir = path.resolve(outputDir, "..", "useJQuery");
|
|
24
25
|
|
|
25
26
|
function useJQueryTests (options) {
|
|
26
|
-
|
|
27
|
+
const {
|
|
28
|
+
port
|
|
29
|
+
} = options;
|
|
30
|
+
|
|
31
|
+
function createOptions (newOptions) {
|
|
32
|
+
const defaultOptions = {
|
|
33
|
+
input: "array",
|
|
34
|
+
source: [ `http://localhost:${port}/nojq` ],
|
|
35
|
+
selector: ".nojq-dynamic",
|
|
36
|
+
outputDir: useJQOutputDir,
|
|
37
|
+
outputDirClean: true,
|
|
38
|
+
browser: "phantomjs",
|
|
39
|
+
timeout,
|
|
40
|
+
useJQuery: true
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
...defaultOptions,
|
|
44
|
+
...newOptions
|
|
45
|
+
};
|
|
46
|
+
}
|
|
27
47
|
|
|
28
48
|
return function () {
|
|
29
49
|
it("should succeed if useJQuery=false, jQuery NOT loaded, dynamic element",
|
|
30
50
|
function (done) {
|
|
31
|
-
|
|
32
|
-
input: "array",
|
|
33
|
-
source: [ "http://localhost:"+port+"/nojq" ],
|
|
34
|
-
selector: ".nojq-dynamic", // nojq-dynamic is created onload
|
|
35
|
-
//selector: "#pocs1",
|
|
36
|
-
outputDir: useJQOutputDir,
|
|
37
|
-
outputDirClean: true,
|
|
38
|
-
timeout: timeout,
|
|
51
|
+
const options = createOptions({
|
|
39
52
|
useJQuery: false
|
|
40
|
-
};
|
|
53
|
+
});
|
|
41
54
|
|
|
42
|
-
ss.run(optHelp.decorate(options),
|
|
55
|
+
ss.run(optHelp.decorate(options), (err, completed) => {
|
|
43
56
|
if (err) {
|
|
44
|
-
console.log(
|
|
57
|
+
console.log(`@@@ error = ${err}, completed=${completed.join(',')}`);
|
|
45
58
|
}
|
|
46
59
|
})
|
|
47
|
-
.then(
|
|
48
|
-
|
|
60
|
+
.then(completed => {
|
|
61
|
+
let assertionError;
|
|
49
62
|
try {
|
|
50
63
|
assert.equal(completed.length, 1);
|
|
51
64
|
assert.equal(completed[0], path.join(useJQOutputDir, "nojq", "index.html"));
|
|
@@ -54,31 +67,27 @@ function useJQueryTests (options) {
|
|
|
54
67
|
}
|
|
55
68
|
cleanup(done, assertionError);
|
|
56
69
|
})
|
|
57
|
-
.catch(
|
|
70
|
+
.catch(e => {
|
|
58
71
|
checkActualFiles(e.notCompleted)
|
|
59
|
-
.then(
|
|
72
|
+
.then(() => {
|
|
60
73
|
cleanup(done, e || unexpectedError);
|
|
61
74
|
});
|
|
62
75
|
});
|
|
63
76
|
});
|
|
64
77
|
|
|
65
78
|
it("should succeed if useJQuery=true, jQuery loaded", function (done) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
source: [ "http://localhost:"+port+"/" ],
|
|
79
|
+
const options = createOptions({
|
|
80
|
+
source: [ `http://localhost:${port}/` ],
|
|
69
81
|
selector: "#dynamic-content",
|
|
70
|
-
outputDir
|
|
71
|
-
|
|
72
|
-
timeout: timeout,
|
|
73
|
-
useJQuery: true
|
|
74
|
-
};
|
|
82
|
+
outputDir
|
|
83
|
+
});
|
|
75
84
|
|
|
76
|
-
ss.run(optHelp.decorate(options),
|
|
85
|
+
ss.run(optHelp.decorate(options), (err, completed) => {
|
|
77
86
|
if (err) {
|
|
78
|
-
console.log(
|
|
87
|
+
console.log(`@@@ error = ${err}, completed=${completed.join(',')}`);
|
|
79
88
|
}
|
|
80
89
|
})
|
|
81
|
-
.then(
|
|
90
|
+
.then(completed => {
|
|
82
91
|
var assertionError;
|
|
83
92
|
try {
|
|
84
93
|
assert.equal(completed.length, 1);
|
|
@@ -88,9 +97,9 @@ function useJQueryTests (options) {
|
|
|
88
97
|
}
|
|
89
98
|
cleanup(done, assertionError);
|
|
90
99
|
})
|
|
91
|
-
.catch(
|
|
100
|
+
.catch(e => {
|
|
92
101
|
checkActualFiles(e.notCompleted)
|
|
93
|
-
.then(
|
|
102
|
+
.then(() => {
|
|
94
103
|
cleanup(done, e || unexpectedError);
|
|
95
104
|
});
|
|
96
105
|
});
|
|
@@ -98,16 +107,12 @@ function useJQueryTests (options) {
|
|
|
98
107
|
|
|
99
108
|
it("should fail if useJQuery is true and no jQuery loads in target page",
|
|
100
109
|
function (done) {
|
|
101
|
-
|
|
102
|
-
input: "array",
|
|
103
|
-
source: [ "http://localhost:"+port+"/nojq" ],
|
|
110
|
+
const options = createOptions({
|
|
104
111
|
selector: "#pocs1",
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
112
|
+
timeout: 4000
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
111
116
|
|
|
112
117
|
ss.run(optHelp.decorate(options), twice)
|
|
113
118
|
.then(unexpectedSuccess.bind(null, done))
|
|
@@ -116,16 +121,12 @@ function useJQueryTests (options) {
|
|
|
116
121
|
|
|
117
122
|
it("should fail if useJQuery is false, no jQuery loads in page, BUT the element is not visible",
|
|
118
123
|
function (done) {
|
|
119
|
-
|
|
120
|
-
input: "array",
|
|
121
|
-
source: [ "http://localhost:"+port+"/nojq" ],
|
|
124
|
+
const options = createOptions({
|
|
122
125
|
selector: ".nojq-notvisible",
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
128
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
126
|
+
timeout: 4000
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
129
130
|
|
|
130
131
|
ss.run(optHelp.decorate(options), twice)
|
|
131
132
|
.then(unexpectedSuccess.bind(null, done))
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* html-snapshots test utilities and constants.
|
|
2
|
+
* html-snapshots test debug utilities and constants.
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var pathExists = require("../../../lib/async/exists");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
const spawn = require("child_process").spawn;
|
|
10
|
+
const assert = require("assert");
|
|
11
|
+
const combineErrors = require("combine-errors");
|
|
12
|
+
const resHelp = require("../../helpers/result");
|
|
13
|
+
const pathExists = require("../../../lib/async/exists");
|
|
15
14
|
|
|
16
15
|
// Constants
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const unexpectedError = new Error("unexpected error flow");
|
|
17
|
+
const outputDir = path.join(__dirname, "./tmp/snapshots");
|
|
18
|
+
const spawnedProcessPattern = "^phantomjs$";
|
|
19
|
+
const bogusFile = "./bogus/file.txt";
|
|
20
|
+
const timeout = 20000;
|
|
22
21
|
|
|
23
22
|
function dumpTree (p) {
|
|
24
|
-
fs.readdirSync(p).forEach(
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
fs.readdirSync(p).forEach(file => {
|
|
24
|
+
const curPath = path.join(p, path.sep, file);
|
|
25
|
+
const stats = fs.statSync(curPath);
|
|
27
26
|
|
|
28
27
|
if (stats.isDirectory()) {
|
|
29
28
|
dumpTree(curPath);
|
|
@@ -34,7 +33,7 @@ function dumpTree (p) {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
function checkActualFiles (files) {
|
|
37
|
-
|
|
36
|
+
let shortFile, outputRoot;
|
|
38
37
|
|
|
39
38
|
if (files.length > 0) {
|
|
40
39
|
shortFile = outputDir;
|
|
@@ -46,7 +45,7 @@ function checkActualFiles (files) {
|
|
|
46
45
|
return prev;
|
|
47
46
|
}, files[0]);
|
|
48
47
|
*/
|
|
49
|
-
|
|
48
|
+
let exists = false; // toggle to dumpTree
|
|
50
49
|
outputRoot = path.dirname(shortFile);
|
|
51
50
|
try {
|
|
52
51
|
fs.statSync(outputRoot).isDirectory();
|
|
@@ -59,9 +58,9 @@ function checkActualFiles (files) {
|
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
return Promise.all(files.map(
|
|
61
|
+
return Promise.all(files.map(file => {
|
|
63
62
|
return pathExists(file)
|
|
64
|
-
.then(
|
|
63
|
+
.then(result => {
|
|
65
64
|
if (result) {
|
|
66
65
|
console.log("@@@ actually exists:" + file);
|
|
67
66
|
}
|
|
@@ -93,10 +92,10 @@ function countSpawnedProcesses (cb) {
|
|
|
93
92
|
if (process.platform === "darwin") {
|
|
94
93
|
wc = spawn("wc", ["-l"]);
|
|
95
94
|
pgrep = spawn("pgrep", [spawnedProcessPattern]);
|
|
96
|
-
pgrep.stdout.on("data",
|
|
95
|
+
pgrep.stdout.on("data", data => {
|
|
97
96
|
wc.stdin.write(data);
|
|
98
97
|
});
|
|
99
|
-
pgrep.stdout.on("end",
|
|
98
|
+
pgrep.stdout.on("end", () => {
|
|
100
99
|
wc.stdin.end();
|
|
101
100
|
});
|
|
102
101
|
wc.stdout.on("data", cb);
|
|
@@ -106,16 +105,16 @@ function countSpawnedProcesses (cb) {
|
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
// Clear any lingering
|
|
108
|
+
// Clear any lingering browser processes in play
|
|
110
109
|
function killSpawnedProcesses (cb) {
|
|
111
110
|
var pkill = spawn("pkill", [spawnedProcessPattern]);
|
|
112
111
|
var guardedCb = _.once(cb);
|
|
113
112
|
|
|
114
|
-
pkill.on("exit",
|
|
113
|
+
pkill.on("exit", () => {
|
|
115
114
|
setTimeout(guardedCb, 2000);
|
|
116
115
|
});
|
|
117
|
-
pkill.on("error",
|
|
118
|
-
guardedCb(new Error("failed to kill
|
|
116
|
+
pkill.on("error", () => {
|
|
117
|
+
guardedCb(new Error("failed to kill browser processes"));
|
|
119
118
|
});
|
|
120
119
|
}
|
|
121
120
|
|
|
@@ -124,8 +123,8 @@ function cleanup (done, arg) {
|
|
|
124
123
|
if (process.platform === "win32") {
|
|
125
124
|
setTimeout(done, 1000, arg);
|
|
126
125
|
} else {
|
|
127
|
-
setImmediate(
|
|
128
|
-
killSpawnedProcesses(
|
|
126
|
+
setImmediate(() => {
|
|
127
|
+
killSpawnedProcesses(err => {
|
|
129
128
|
done(multiError(err, arg));
|
|
130
129
|
});
|
|
131
130
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
User-agent: *
|
|
2
|
+
|
|
3
|
+
Allow: /
|
|
4
|
+
Allow: /contact
|
|
5
|
+
Allow: /services/carpets
|
|
6
|
+
Allow: /services/test?arg=one
|
|
7
|
+
Allow: /services/#hash
|
|
8
|
+
|
|
9
|
+
Disallow: /api/
|
|
10
|
+
Disallow: /vendor/
|
|
11
|
+
Disallow: /fonts/
|
|
12
|
+
Disallow: /images/
|
|
13
|
+
|
|
14
|
+
Sitemap: http://localhost:8033/test_sitemap.xml
|
|
15
|
+
|
|
16
|
+
User-agent: ia_archiver
|
|
17
|
+
Disallow: /
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
User-agent: *
|
|
2
|
+
|
|
3
|
+
Allow: /
|
|
4
|
+
Allow: /contact
|
|
5
|
+
Allow: /services/carpets
|
|
6
|
+
Allow: /services/test?arg=one
|
|
7
|
+
Allow: /services/#hash
|
|
8
|
+
|
|
9
|
+
Disallow: /api/
|
|
10
|
+
Disallow: /vendor/
|
|
11
|
+
Disallow: /fonts/
|
|
12
|
+
Disallow: /images/
|
|
13
|
+
|
|
14
|
+
Sitemap: http://badhost.nowhere/sitemap.xml
|
|
15
|
+
|
|
16
|
+
User-agent: ia_archiver
|
|
17
|
+
Disallow: /
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
User-agent: *
|
|
2
|
+
|
|
3
|
+
Allow: /
|
|
4
|
+
Allow: /contact
|
|
5
|
+
Allow: /services/carpets
|
|
6
|
+
Allow: /services/test?arg=one
|
|
7
|
+
Allow: /services/#hash
|
|
8
|
+
|
|
9
|
+
Disallow: /api/
|
|
10
|
+
Disallow: /vendor/
|
|
11
|
+
Disallow: /fonts/
|
|
12
|
+
Disallow: /images/
|
|
13
|
+
|
|
14
|
+
Sitemap: http://localhost:8033/test_sitemap.xml
|
|
15
|
+
Sitemap: http://localhost:8033/test_sitemap_index.xml
|
|
16
|
+
|
|
17
|
+
User-agent: ia_archiver
|
|
18
|
+
Disallow: /
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global describe, it, before */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// var options = require("../../helpers/options");
|
|
7
|
+
const assert = require("assert");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const factory = require("../../../lib/input-generators");
|
|
10
|
+
const server = require("../../server");
|
|
11
|
+
const options = require("../../helpers/options");
|
|
13
12
|
// var smHelper = require("../../helpers/sitemap");
|
|
14
|
-
|
|
13
|
+
const port = 9334;
|
|
15
14
|
|
|
16
15
|
describe("input-generator", function () {
|
|
17
16
|
|
|
@@ -19,13 +18,70 @@ describe("input-generator", function () {
|
|
|
19
18
|
// This is just about specific sitemap index option processing
|
|
20
19
|
|
|
21
20
|
describe("sitemap-index", function () {
|
|
21
|
+
let gen;
|
|
22
|
+
const outputDir = path.join(__dirname, "snapshots");
|
|
23
|
+
|
|
24
|
+
function createOptions (overrideOptions) {
|
|
25
|
+
const basicOptions = {
|
|
26
|
+
input: "sitemap-index",
|
|
27
|
+
outputDirClean: true,
|
|
28
|
+
outputDir,
|
|
29
|
+
port
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
...basicOptions,
|
|
33
|
+
...overrideOptions
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function fail (done, message) {
|
|
38
|
+
const msg = message.toString();
|
|
39
|
+
assert.fail(msg);
|
|
40
|
+
done(new Error(msg));
|
|
41
|
+
}
|
|
22
42
|
|
|
23
43
|
before(function () {
|
|
24
|
-
|
|
44
|
+
server.start(path.join(__dirname, "./server"), port);
|
|
45
|
+
gen = factory.create("sitemap-index");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should handle empty sitemap-index", function (done) {
|
|
49
|
+
const source = `http://localhost:${port}/test_sitemap_index_empty.xml`;
|
|
50
|
+
const opts = createOptions({
|
|
51
|
+
source,
|
|
52
|
+
_abort: err => {
|
|
53
|
+
const msg = `empty sitemap-index should not abort, ${err}`;
|
|
54
|
+
fail(done, msg);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = gen.run(options.decorate(opts), () => {
|
|
59
|
+
fail(done, "empty sitemap-index should not produce input");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
result.then(() => done()).catch(fail.bind(null, done));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should handle malformed sitemap-index", function (done) {
|
|
66
|
+
const source = `http://localhost:${port}/test_sitemap_index_malformed.xml`;
|
|
67
|
+
const opts = createOptions({
|
|
68
|
+
source,
|
|
69
|
+
_abort: err => {
|
|
70
|
+
assert.equal(true, !!err, `${source} should have aborted with error`);
|
|
71
|
+
done();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const result = gen.run(
|
|
76
|
+
options.decorate(opts),
|
|
77
|
+
fail.bind(null, done, `Input handler was called unexpectedly for badSource: ${source}`)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
result.then(() => assert.ok(true)).catch(fail.bind(null, done));
|
|
25
81
|
});
|
|
26
82
|
|
|
27
83
|
it("TODO: write specific sitemap-index tests", function () {
|
|
28
84
|
assert.ok(true);
|
|
29
|
-
})
|
|
85
|
+
});
|
|
30
86
|
});
|
|
31
87
|
});
|