html-snapshots 0.18.2 → 0.19.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/README.md +73 -68
- package/examples/custom/myFilter.js +2 -2
- package/examples/custom/package-lock.json +1012 -77
- package/examples/custom/package.json +1 -1
- package/examples/custom/snapshot.js +8 -10
- package/examples/debug-phantomjs/package-lock.json +76 -76
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +12 -14
- package/examples/html5rocks/package-lock.json +1379 -78
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +15 -18
- package/examples/process-limit/package-lock.json +1379 -78
- package/examples/process-limit/package.json +1 -1
- package/examples/process-limit/snapshot.js +8 -10
- package/examples/simple-promise/package-lock.json +1379 -78
- package/examples/simple-promise/package.json +1 -1
- package/examples/simple-promise/snapshot.js +6 -8
- package/examples/sitemap-index/package-lock.json +1378 -77
- 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 +1380 -78
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +11 -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 +0 -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/package.json +6 -6
- package/test/helpers/options.js +4 -2
- package/test/mocha/html-snapshots/process-limit.js +46 -48
- package/test/mocha/html-snapshots/robots.js +156 -138
- 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 +58 -57
- package/test/mocha/html-snapshots/snapshot-scripts.js +55 -54
- package/test/mocha/html-snapshots/test.js +16 -16
- package/test/mocha/html-snapshots/test_robots.txt +0 -2
- package/test/mocha/html-snapshots/utils.js +0 -1
- 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,156 +4,174 @@
|
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var urls = 3; // must match test_robots.txt
|
|
7
|
+
const rimraf = require("rimraf").sync;
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
const common = require("../../../lib/common");
|
|
10
|
+
const optHelp = require("../../helpers/options");
|
|
11
|
+
const ss = require("../../../lib/html-snapshots");
|
|
12
|
+
const utils = require("./utils");
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
timeout,
|
|
16
|
+
outputDir,
|
|
17
|
+
cleanup,
|
|
18
|
+
cleanupSuccess,
|
|
19
|
+
cleanupError,
|
|
20
|
+
testSuccess,
|
|
21
|
+
bogusFile,
|
|
22
|
+
unexpectedSuccess,
|
|
23
|
+
checkActualFiles
|
|
24
|
+
} = utils;
|
|
25
|
+
|
|
26
|
+
const urls = 3; // must match url # in robots files test fixtures.
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* The robots test suite.
|
|
31
30
|
*/
|
|
32
31
|
function robotsTests (options) {
|
|
33
|
-
|
|
32
|
+
const { port, localRobotsFile } = options;
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
selector: "#dynamic-content",
|
|
42
|
-
outputDir: outputDir,
|
|
43
|
-
outputDirClean: true,
|
|
44
|
-
timeout: timeout
|
|
45
|
-
};
|
|
46
|
-
var twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
47
|
-
|
|
48
|
-
rimraf(outputDir);
|
|
49
|
-
|
|
50
|
-
ss.run(optHelp.decorate(options), twice)
|
|
51
|
-
.then(testSuccess.bind(null, twice))
|
|
52
|
-
.catch(function (e) {
|
|
53
|
-
checkActualFiles(e.notCompleted)
|
|
54
|
-
.then(function () {
|
|
55
|
-
cleanup(done, e);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should all succeed, output dir does pre-exist", function (done) {
|
|
61
|
-
var options = {
|
|
62
|
-
source: inputFile,
|
|
63
|
-
hostname: "localhost",
|
|
64
|
-
port: port,
|
|
65
|
-
selector: "#dynamic-content",
|
|
66
|
-
outputDir: outputDir,
|
|
67
|
-
outputDirClean: true,
|
|
68
|
-
timeout: timeout
|
|
69
|
-
};
|
|
70
|
-
var twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
71
|
-
|
|
72
|
-
ss.run(optHelp.decorate(options), twice)
|
|
73
|
-
.then(testSuccess.bind(null, twice))
|
|
74
|
-
.catch(function (e) {
|
|
75
|
-
checkActualFiles(e.notCompleted)
|
|
76
|
-
.then(function () {
|
|
77
|
-
cleanup(done, e);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should all fail with bad phantomjs process to spawn",
|
|
83
|
-
function (done) {
|
|
84
|
-
var options = {
|
|
85
|
-
source: inputFile,
|
|
86
|
-
hostname: "localhost",
|
|
87
|
-
port: port,
|
|
88
|
-
selector: "#dynamic-content",
|
|
89
|
-
outputDir: outputDir,
|
|
90
|
-
outputDirClean: true,
|
|
91
|
-
phantomjs: bogusFile,
|
|
92
|
-
timeout: 1000
|
|
93
|
-
};
|
|
94
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
95
|
-
|
|
96
|
-
ss.run(options, twice)
|
|
97
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
98
|
-
.catch(twice);
|
|
99
|
-
});
|
|
34
|
+
// Robots.txt fixtures
|
|
35
|
+
const inputFiles = [
|
|
36
|
+
localRobotsFile,
|
|
37
|
+
`http://localhost:${port}/test_robots.txt`,
|
|
38
|
+
`http://localhost:${port}/test_robots_sitemap.txt`
|
|
39
|
+
];
|
|
100
40
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
41
|
+
return function () {
|
|
42
|
+
inputFiles.forEach(inputFile => {
|
|
43
|
+
it(`should succeed, no output dir pre-exists, ${inputFile}`, function (done) {
|
|
44
|
+
const options = {
|
|
45
|
+
source: inputFile,
|
|
46
|
+
hostname: "localhost",
|
|
47
|
+
selector: "#dynamic-content",
|
|
48
|
+
outputDirClean: true,
|
|
49
|
+
outputDir,
|
|
50
|
+
timeout,
|
|
51
|
+
port
|
|
52
|
+
};
|
|
53
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
54
|
+
|
|
55
|
+
rimraf(outputDir);
|
|
56
|
+
|
|
57
|
+
ss.run(optHelp.decorate(options), twice)
|
|
58
|
+
.then(testSuccess.bind(null, twice))
|
|
59
|
+
.catch(e => {
|
|
60
|
+
checkActualFiles(e.notCompleted)
|
|
61
|
+
.then(() => {
|
|
62
|
+
cleanup(done, e);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it(`should succeed, output dir does pre-exist, ${inputFile}`, function (done) {
|
|
68
|
+
const options = {
|
|
69
|
+
source: inputFile,
|
|
70
|
+
hostname: "localhost",
|
|
71
|
+
selector: "#dynamic-content",
|
|
72
|
+
outputDirClean: true,
|
|
73
|
+
outputDir,
|
|
74
|
+
timeout,
|
|
75
|
+
port
|
|
76
|
+
};
|
|
77
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
78
|
+
|
|
79
|
+
ss.run(optHelp.decorate(options), twice)
|
|
80
|
+
.then(testSuccess.bind(null, twice))
|
|
81
|
+
.catch(e => {
|
|
82
|
+
checkActualFiles(e.notCompleted)
|
|
83
|
+
.then(() => {
|
|
84
|
+
cleanup(done, e);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it(`should fail with bad phantomjs process to spawn, ${inputFile}`,
|
|
90
|
+
function (done) {
|
|
91
|
+
const options = {
|
|
92
|
+
source: inputFile,
|
|
93
|
+
hostname: "localhost",
|
|
94
|
+
selector: "#dynamic-content",
|
|
95
|
+
outputDirClean: true,
|
|
96
|
+
phantomjs: bogusFile,
|
|
97
|
+
timeout: 1000,
|
|
98
|
+
outputDir,
|
|
99
|
+
port
|
|
100
|
+
};
|
|
101
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
102
|
+
|
|
103
|
+
ss.run(options, twice)
|
|
104
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
105
|
+
.catch(twice);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it(`should fail, bad remote robots, ${inputFile}`, function (done) {
|
|
109
|
+
const options = {
|
|
110
|
+
input: "robots",
|
|
111
|
+
source: `http://localhost:${port}/index.html`,
|
|
112
|
+
selector: "#dynamic-content",
|
|
113
|
+
outputDirClean: true,
|
|
114
|
+
timeout: 6000,
|
|
115
|
+
outputDir,
|
|
116
|
+
port
|
|
117
|
+
};
|
|
118
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
119
|
+
|
|
120
|
+
ss.run(optHelp.decorate(options), twice)
|
|
121
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
122
|
+
.catch(twice);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it(`should fail, non-existent selector, ${inputFile}`, function (done) {
|
|
126
|
+
const options = {
|
|
127
|
+
source: inputFile,
|
|
128
|
+
hostname: "localhost",
|
|
129
|
+
selector: "#dynamic-content-notexist",
|
|
130
|
+
outputDirClean: true,
|
|
131
|
+
timeout: 6000,
|
|
132
|
+
outputDir,
|
|
133
|
+
port
|
|
134
|
+
};
|
|
135
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
136
|
+
|
|
137
|
+
ss.run(optHelp.decorate(options), twice)
|
|
138
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
139
|
+
.catch(twice);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it(`should fail one snapshot, one non-existent selector, ${inputFile}`, function (done) {
|
|
143
|
+
let exceptionUrl = "/";
|
|
144
|
+
if (common.isUrl(inputFile)) {
|
|
145
|
+
// assume the origin of the inputFile is the same as the contents of the remote urls within it.
|
|
146
|
+
const url = new URL(inputFile);
|
|
147
|
+
const isSitemap = url.pathname.includes('sitemap');
|
|
148
|
+
if (isSitemap) {
|
|
149
|
+
exceptionUrl = `${url.origin}${exceptionUrl}`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const options = {
|
|
153
|
+
source: inputFile,
|
|
154
|
+
hostname: "localhost",
|
|
155
|
+
selector: {
|
|
156
|
+
"__default": "#dynamic-content",
|
|
157
|
+
[exceptionUrl]: "#dynamic-content-notexist"
|
|
158
|
+
},
|
|
159
|
+
outputDirClean: true,
|
|
160
|
+
timeout: 6000,
|
|
161
|
+
outputDir,
|
|
162
|
+
port
|
|
163
|
+
};
|
|
164
|
+
const twice = _.after(2, cleanupError.bind(null, done, urls - 1));
|
|
165
|
+
|
|
166
|
+
ss.run(optHelp.decorate(options), twice)
|
|
167
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
168
|
+
.catch(twice);
|
|
169
|
+
});
|
|
151
170
|
});
|
|
152
171
|
};
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
module.exports = {
|
|
156
175
|
testSuite: robotsTests,
|
|
157
|
-
inputFile: inputFile,
|
|
158
176
|
urlCount: urls
|
|
159
177
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
User-agent: *
|
|
2
|
+
|
|
3
|
+
Allow: /
|
|
4
|
+
Allow: /contact
|
|
5
|
+
Allow: /services/carpets
|
|
6
|
+
|
|
7
|
+
Disallow: /api/
|
|
8
|
+
Disallow: /vendor/
|
|
9
|
+
Disallow: /fonts/
|
|
10
|
+
Disallow: /images/
|
|
11
|
+
|
|
12
|
+
User-agent: ia_archiver
|
|
13
|
+
Disallow: /
|
|
14
|
+
|
|
15
|
+
Sitemap: http://localhost:8038/test_robots_sitemap.xml
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
|
|
3
|
+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
4
|
+
<url>
|
|
5
|
+
<loc>http://localhost:8038/</loc>
|
|
6
|
+
<lastmod>2012-08-11T12:16:09+00:00</lastmod>
|
|
7
|
+
<changefreq>daily</changefreq>
|
|
8
|
+
<priority>1.0</priority>
|
|
9
|
+
</url>
|
|
10
|
+
<url>
|
|
11
|
+
<loc>http://localhost:8038/contact</loc>
|
|
12
|
+
<lastmod>2012-11-02T02:53:40+00:00</lastmod>
|
|
13
|
+
<changefreq>weekly</changefreq>
|
|
14
|
+
<priority>0.6</priority>
|
|
15
|
+
</url>
|
|
16
|
+
<url>
|
|
17
|
+
<loc>http://localhost:8038/services/carpets</loc>
|
|
18
|
+
<lastmod>2012-10-19T10:45:23+00:00</lastmod>
|
|
19
|
+
<changefreq>weekly</changefreq>
|
|
20
|
+
<priority>0.6</priority>
|
|
21
|
+
</url>
|
|
22
|
+
</urlset>
|
|
@@ -4,48 +4,49 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global it */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const assert = require("assert");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const optHelp = require("../../helpers/options");
|
|
10
|
+
const ss = require("../../../lib/html-snapshots");
|
|
11
|
+
const utils = require("./utils");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const {
|
|
14
|
+
outputDir,
|
|
15
|
+
timeout,
|
|
16
|
+
unexpectedError,
|
|
17
|
+
unexpectedSuccess,
|
|
18
|
+
cleanup,
|
|
19
|
+
checkActualFiles
|
|
20
|
+
} = utils;
|
|
20
21
|
|
|
21
22
|
// Sitemap-index constants
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const sitemapIndexFile = "test_sitemap_index.xml";
|
|
24
|
+
const inputFile = path.join(__dirname, "./", sitemapIndexFile);
|
|
25
|
+
const urls = 3; // must match the unqiue # of urls in all the sitemap files referenced in sitemap-index.
|
|
25
26
|
|
|
26
27
|
function getClass (obj) {
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const string = Object.prototype.toString.call(obj);
|
|
29
|
+
const m = /\[object ([^\]]+)/.exec(string);
|
|
29
30
|
return m && m[1];
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
function sitemapIndexTests (options) {
|
|
33
|
-
|
|
34
|
+
const port = options.port;
|
|
34
35
|
|
|
35
36
|
return function () {
|
|
36
37
|
it("should succeed for typical sitemap-index usage", function (done) {
|
|
37
|
-
|
|
38
|
-
source:
|
|
38
|
+
const options = {
|
|
39
|
+
source: `http://localhost:${port}/${sitemapIndexFile}`,
|
|
39
40
|
input: "sitemap-index",
|
|
40
41
|
selector: "#dynamic-content",
|
|
41
|
-
outputDir: outputDir,
|
|
42
42
|
outputDirClean: true,
|
|
43
|
-
|
|
43
|
+
outputDir,
|
|
44
|
+
timeout
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
ss.run(optHelp.decorate(options))
|
|
47
48
|
.then(function (completed) {
|
|
48
|
-
|
|
49
|
+
let assertionError;
|
|
49
50
|
try {
|
|
50
51
|
assert.equal(getClass(completed), "Array");
|
|
51
52
|
assert.equal(completed.length, urls);
|
|
@@ -54,61 +55,61 @@ function sitemapIndexTests (options) {
|
|
|
54
55
|
}
|
|
55
56
|
cleanup(done, assertionError);
|
|
56
57
|
})
|
|
57
|
-
.catch(
|
|
58
|
+
.catch(err => {
|
|
58
59
|
checkActualFiles(err.notCompleted)
|
|
59
|
-
.then(
|
|
60
|
+
.then(() => {
|
|
60
61
|
cleanup(done, err || unexpectedError);
|
|
61
62
|
});
|
|
62
63
|
});
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
it("should fail fast for bad sitemap url", function (done) {
|
|
66
|
-
|
|
67
|
+
const sitemapIndexFile3 = path.basename(sitemapIndexFile, ".xml") + "-3" +
|
|
67
68
|
path.extname(sitemapIndexFile);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const options = {
|
|
70
|
+
source: `http://localhost:${port}/${sitemapIndexFile3}`,
|
|
71
|
+
input: "sitemap-index",
|
|
72
|
+
selector: "#dynamic-content",
|
|
73
|
+
outputDirClean: true,
|
|
74
|
+
outputDir,
|
|
75
|
+
timeout
|
|
76
|
+
};
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
ss.run(optHelp.decorate(options))
|
|
79
|
+
.then(unexpectedSuccess)
|
|
80
|
+
.catch(err => {
|
|
81
|
+
let assertionError;
|
|
82
|
+
try {
|
|
83
|
+
assert.equal(getClass(err.notCompleted), "Array");
|
|
84
|
+
// fails fast:
|
|
85
|
+
assert.equal(err.notCompleted.length, 0);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
assertionError = e;
|
|
88
|
+
}
|
|
89
|
+
cleanup(done, assertionError);
|
|
90
|
+
});
|
|
90
91
|
});
|
|
91
92
|
|
|
92
93
|
it("should eventually fail for bad page url", function (done) {
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
const eventually = 1000;
|
|
95
|
+
const sitemapIndexFile2 = path.basename(sitemapIndexFile, ".xml") + "-2" +
|
|
95
96
|
path.extname(sitemapIndexFile);
|
|
96
|
-
|
|
97
|
-
source:
|
|
97
|
+
const options = {
|
|
98
|
+
source: `http://localhost:${port}/${sitemapIndexFile2}`,
|
|
98
99
|
input: "sitemap-index",
|
|
99
100
|
selector: "#dynamic-content",
|
|
100
|
-
outputDir: outputDir,
|
|
101
101
|
outputDirClean: true,
|
|
102
102
|
timeout: {
|
|
103
103
|
"http://localhost:8040/services/bad": eventually,
|
|
104
104
|
__default: timeout
|
|
105
|
-
}
|
|
105
|
+
},
|
|
106
|
+
outputDir
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
ss.run(optHelp.decorate(options))
|
|
109
110
|
.then(unexpectedSuccess)
|
|
110
|
-
.catch(
|
|
111
|
-
|
|
111
|
+
.catch(err => {
|
|
112
|
+
let assertionError;
|
|
112
113
|
try {
|
|
113
114
|
assert.equal(getClass(err.completed), "Array");
|
|
114
115
|
assert.equal(err.completed.length, urls - 1);
|
|
@@ -125,6 +126,6 @@ function sitemapIndexTests (options) {
|
|
|
125
126
|
|
|
126
127
|
module.exports = {
|
|
127
128
|
testSuite: sitemapIndexTests,
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
urlCount: urls,
|
|
130
|
+
inputFile
|
|
130
131
|
};
|