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.
Files changed (84) hide show
  1. package/.eslintrc.json +4 -5
  2. package/.github/workflows/verify.yml +2 -2
  3. package/HISTORY.md +42 -0
  4. package/README.md +109 -256
  5. package/examples/README.md +149 -0
  6. package/examples/custom/myFilter.js +2 -2
  7. package/examples/custom/package-lock.json +2021 -5
  8. package/examples/custom/package.json +1 -1
  9. package/examples/custom/snapshot.js +8 -10
  10. package/examples/debug-phantomjs/package-lock.json +6 -6
  11. package/examples/debug-phantomjs/package.json +1 -1
  12. package/examples/debug-phantomjs/snapshot.js +13 -14
  13. package/examples/debug-puppeteer/README.md +18 -0
  14. package/examples/debug-puppeteer/package-lock.json +2804 -0
  15. package/examples/debug-puppeteer/package.json +12 -0
  16. package/examples/debug-puppeteer/snapshot.js +30 -0
  17. package/examples/html5rocks/package-lock.json +1306 -5
  18. package/examples/html5rocks/package.json +1 -1
  19. package/examples/html5rocks/snapshot.js +14 -23
  20. package/examples/process-limit/package-lock.json +1306 -5
  21. package/examples/process-limit/package.json +1 -1
  22. package/examples/process-limit/snapshot.js +8 -10
  23. package/examples/simple-promise/package-lock.json +1306 -5
  24. package/examples/simple-promise/package.json +1 -1
  25. package/examples/simple-promise/snapshot.js +6 -8
  26. package/examples/sitemap-index/package-lock.json +1306 -5
  27. package/examples/sitemap-index/package.json +1 -1
  28. package/examples/sitemap-index/snapshot.js +6 -6
  29. package/examples/utils/index.js +2 -4
  30. package/examples/verbose/package-lock.json +1306 -5
  31. package/examples/verbose/package.json +1 -1
  32. package/examples/verbose/snapshot.js +12 -14
  33. package/lib/async/index.js +0 -1
  34. package/lib/common/index.js +1 -1
  35. package/lib/common/sitemap/index.js +16 -0
  36. package/lib/common/sitemap/sitemap-collection.js +94 -0
  37. package/lib/common/sitemap/sitemap-index.js +68 -0
  38. package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
  39. package/lib/html-snapshots.js +87 -5
  40. package/lib/input-generators/_base.js +7 -1
  41. package/lib/input-generators/array.js +0 -1
  42. package/lib/input-generators/robots.js +98 -58
  43. package/lib/input-generators/sitemap-index.js +3 -124
  44. package/lib/input-generators/sitemap.js +3 -7
  45. package/lib/input-generators/textfile.js +2 -6
  46. package/lib/puppeteer/index.js +98 -0
  47. package/lib/puppeteer/removeScripts.js +8 -0
  48. package/package.json +9 -4
  49. package/test/helpers/options.js +4 -2
  50. package/test/mocha/browsers/puppeteer.js +106 -0
  51. package/test/mocha/browsers/server/index.html +9 -0
  52. package/test/mocha/browsers/test.js +11 -0
  53. package/test/mocha/html-snapshots/basics.js +60 -47
  54. package/test/mocha/html-snapshots/phantomjs-options.js +54 -60
  55. package/test/mocha/html-snapshots/process-limit.js +126 -120
  56. package/test/mocha/html-snapshots/puppeteer.js +47 -0
  57. package/test/mocha/html-snapshots/robots.js +156 -121
  58. package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
  59. package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
  60. package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
  61. package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
  62. package/test/mocha/html-snapshots/sitemap-index.js +100 -90
  63. package/test/mocha/html-snapshots/sitemap.js +75 -31
  64. package/test/mocha/html-snapshots/snapshot-scripts.js +150 -145
  65. package/test/mocha/html-snapshots/test.js +23 -14
  66. package/test/mocha/html-snapshots/test_robots.txt +0 -2
  67. package/test/mocha/html-snapshots/use-jquery.js +65 -64
  68. package/test/mocha/html-snapshots/utils.js +29 -30
  69. package/test/mocha/input-generators/server/test_robots.txt +0 -2
  70. package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
  71. package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
  72. package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
  73. package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
  74. package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
  75. package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
  76. package/test/mocha/input-generators/sitemap-index.js +65 -9
  77. package/test/mocha/input-generators/test.js +276 -280
  78. package/test/mocha/input-generators/test_robots.txt +0 -2
  79. package/test/mocha/input-generators/test_robots_bad.txt +0 -2
  80. package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
  81. package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
  82. package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
  83. package/lib/common/node.js +0 -26
  84. package/test/mocha/common/node.js +0 -100
@@ -4,14 +4,14 @@
4
4
  * Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
5
5
  */
6
6
  /* global describe, it, before */
7
- var assert = require("assert");
8
- var path = require("path");
9
- var base = require("../../../lib/input-generators/_base");
10
- var factory = require("../../../lib/input-generators");
11
- var common = require("../../../lib/common");
12
- var server = require("../../server");
13
- var options = require("../../helpers/options");
14
- var port = 8033;
7
+ const assert = require("assert");
8
+ const path = require("path");
9
+ const base = require("../../../lib/input-generators/_base");
10
+ const factory = require("../../../lib/input-generators");
11
+ const common = require("../../../lib/common");
12
+ const server = require("../../server");
13
+ const options = require("../../helpers/options");
14
+ const port = 8033;
15
15
 
16
16
  describe("input-generator", function () {
17
17
 
@@ -49,17 +49,22 @@ describe("input-generator", function () {
49
49
  });
50
50
  });
51
51
 
52
- var thisOutputDir = path.join(__dirname, "snapshots");
52
+ const thisOutputDir = path.join(__dirname, "snapshots");
53
53
 
54
- var inputGenerators = [
54
+ const inputGenerators = [
55
55
  {
56
56
  name: "robots",
57
57
  input: factory.create("robots"),
58
58
  source: path.join(__dirname, "test_robots.txt"),
59
- remote: "http://localhost:"+port+"/test_robots.txt",
59
+ remote: [
60
+ `http://localhost:${port}/test_robots.txt`,
61
+ `http://localhost:${port}/test_robots_sitemap.txt`,
62
+ `http://localhost:${port}/test_robots_sitemap_multi.txt`
63
+ ],
60
64
  bad: [
61
65
  path.join(__dirname, "test_robots_bad.txt"),
62
- "http://localhost:"+port+"/test_robots_bad.txt"
66
+ `http://localhost:${port}/test_robots_bad.txt`,
67
+ `http://localhost:${port}/test_robots_sitemap_bad.txt`
63
68
  ],
64
69
  urls: 5
65
70
  },
@@ -84,17 +89,17 @@ describe("input-generator", function () {
84
89
  name: "sitemap",
85
90
  input: factory.create("sitemap"),
86
91
  source: path.join(__dirname, "test_sitemap.xml"),
87
- remote: "http://localhost:"+port+"/test_sitemap.xml",
92
+ remote: [`http://localhost:${port}/test_sitemap.xml`],
88
93
  urls: 5
89
94
  },
90
95
  {
91
96
  name: "sitemap-gzip",
92
97
  input: factory.create("sitemap"),
93
98
  source: path.join(__dirname, "test_sitemap.xml.gz"),
94
- remote: "http://localhost:"+port+"/test_sitemap.xml.gz",
99
+ remote: [`http://localhost:${port}/test_sitemap.xml.gz`],
95
100
  bad: [
96
101
  path.join(__dirname, "test_sitemap_bad.xml.gz"),
97
- "http://localhost:"+port+"/test_sitemap_bad.xml.gz"
102
+ `http://localhost:${port}/test_sitemap_bad.xml.gz`
98
103
  ],
99
104
  urls: 5
100
105
  },
@@ -102,7 +107,7 @@ describe("input-generator", function () {
102
107
  name: "sitemap-index",
103
108
  input: factory.create("sitemap-index"),
104
109
  source: path.join(__dirname, "test_sitemap_index.xml"),
105
- remote: "http://localhost:"+port+"/test_sitemap_index.xml",
110
+ remote: [`http://localhost:${port}/test_sitemap_index.xml`],
106
111
  // this is the total number of pages referenced by sitemaps in test_sitemap_index.
107
112
  urls: 17
108
113
  },
@@ -110,7 +115,7 @@ describe("input-generator", function () {
110
115
  name: "sitemap-index-gzip",
111
116
  input: factory.create("sitemap-index"),
112
117
  source: path.join(__dirname, "test_sitemap_index.xml.gz"),
113
- remote: "http://localhost:"+port+"/test_sitemap_index.xml.gz",
118
+ remote: [`http://localhost:${port}/test_sitemap_index.xml.gz`],
114
119
  // this is the total number of pages referenced by sitemaps in test_sitemap_index.
115
120
  urls: 17
116
121
  }
@@ -128,7 +133,7 @@ describe("input-generator", function () {
128
133
  }
129
134
 
130
135
  function urlToPath (url) {
131
- var result = url;
136
+ let result = url;
132
137
  if (process.platform === "win32") {
133
138
  result = url.replace(/\//g, "\\");
134
139
  }
@@ -136,7 +141,7 @@ describe("input-generator", function () {
136
141
  }
137
142
 
138
143
  function urlToPathRe (url) {
139
- var result = url;
144
+ let result = url;
140
145
  if (process.platform === "win32") {
141
146
  result = url.replace(/\//g, "\\\\");
142
147
  }
@@ -147,13 +152,12 @@ describe("input-generator", function () {
147
152
 
148
153
  describe(inputGeneratorTest.name, function () {
149
154
 
150
- var globalUrl = inputGeneratorTest.name === "robots" || inputGeneratorTest.name === "textfile";
151
- // var genName = inputGeneratorTest.name;
152
- var remote = inputGeneratorTest.remote;
153
- var gen = inputGeneratorTest.input;
154
- var source = inputGeneratorTest.source;
155
- var bad = inputGeneratorTest.bad;
156
- var urls = inputGeneratorTest.urls;
155
+ const globalUrl = inputGeneratorTest.name === "robots" || inputGeneratorTest.name === "textfile";
156
+ const remote = inputGeneratorTest.remote;
157
+ const gen = inputGeneratorTest.input;
158
+ const source = inputGeneratorTest.source;
159
+ const bad = inputGeneratorTest.bad;
160
+ const urls = inputGeneratorTest.urls;
157
161
 
158
162
  describe("general behavior", function () {
159
163
 
@@ -167,7 +171,7 @@ describe("input-generator", function () {
167
171
 
168
172
  // requires inputFile not found
169
173
  it("should produce no input for defaults and a bogus file", function (done) {
170
- var doneCalled = false;
174
+ let doneCalled = false;
171
175
 
172
176
  gen.run(options.decorate({
173
177
  source: "./bogus/file.txt",
@@ -178,7 +182,7 @@ describe("input-generator", function () {
178
182
  done();
179
183
  }
180
184
  }), function () {
181
- assert.fail("input callback", "called", "unexpected input processed", "should not have been");
185
+ assert.fail("input callback should not have been called, unexpected input processed");
182
186
  });
183
187
 
184
188
  setTimeout(function () {
@@ -190,9 +194,9 @@ describe("input-generator", function () {
190
194
 
191
195
  // requires source to have 'urls' valid entries
192
196
  it("should produce input with all defaults and a valid source", function (done) {
193
- var count = 0;
197
+ let count = 0;
194
198
 
195
- var result = gen.run(options.decorate({
199
+ const result = gen.run(options.decorate({
196
200
  source: source,
197
201
  outputDir: thisOutputDir
198
202
  }), function () {
@@ -207,25 +211,25 @@ describe("input-generator", function () {
207
211
  assert.ok(true);
208
212
  })
209
213
  .catch(function (err) {
210
- assert.fail("run", "fail", err.toString(), "should not");
214
+ assert.fail(`Run should not fail: ${err.toString()}`);
211
215
  });
212
216
  });
213
217
 
214
218
  // this test has to match the base generator defaults
215
219
  it("base defaults should exist in input when requested", function (done) {
216
- var defaults = base.defaults({});
220
+ const defaults = base.defaults({});
217
221
  defaults.outputDir = thisOutputDir;
218
222
 
219
- var count = 0;
220
- var result = gen.run(options.decorate({
223
+ let count = 0;
224
+ const result = gen.run(options.decorate({
221
225
  source: source,
222
226
  outputDir: thisOutputDir
223
227
  }), function (input) {
224
- var re1 = new RegExp("^("+defaults.protocol+")://("+defaults.hostname+")/");
225
- var re2 = new RegExp("^("+pathToRe(defaults.outputDir)+")"+pathToRe(path.sep));
228
+ const re1 = new RegExp("^("+defaults.protocol+")://("+defaults.hostname+")/");
229
+ const re2 = new RegExp("^("+pathToRe(defaults.outputDir)+")"+pathToRe(path.sep));
226
230
 
227
- var m1 = re1.exec(input.url);
228
- var m2 = re2.exec(input.outputFile);
231
+ const m1 = re1.exec(input.url);
232
+ const m2 = re2.exec(input.outputFile);
229
233
 
230
234
  if (globalUrl) {
231
235
  assert.equal(m1[1], defaults.protocol);
@@ -250,7 +254,7 @@ describe("input-generator", function () {
250
254
  assert.ok(true);
251
255
  })
252
256
  .catch(function (err) {
253
- assert.fail("run", "fail", err.toString(), "should not");
257
+ assert.fail(`Run should not fail: ${err.toString()}`);
254
258
  });
255
259
  });
256
260
 
@@ -259,10 +263,10 @@ describe("input-generator", function () {
259
263
  describe("timeout option", function () {
260
264
 
261
265
  it("should accept scalar and apply globally", function (done) {
262
- var count = 0;
263
- var theTimeout = 500;
266
+ let count = 0;
267
+ const theTimeout = 500;
264
268
 
265
- var result = gen.run(options.decorate({
269
+ const result = gen.run(options.decorate({
266
270
  source: source,
267
271
  outputDir: thisOutputDir,
268
272
  timeout: theTimeout
@@ -280,37 +284,37 @@ describe("input-generator", function () {
280
284
  assert.ok(true);
281
285
  })
282
286
  .catch(function (err) {
283
- assert.fail("run", "fail", err.toString(), "should not");
287
+ assert.fail(`Run should not fail: ${err.toString()}`);
284
288
  });
285
289
  });
286
290
 
287
291
  // requires source to contain specific urls
288
292
  it("should accept function and apply per url", function (done) {
289
- var globalTimeouts = {
293
+ const globalTimeouts = {
290
294
  "/": 1,
291
295
  "/contact": 2,
292
296
  "/services/carpets": 3
293
297
  };
294
- var localTimeouts = {
298
+ const localTimeouts = {
295
299
  "http://northstar.local": 1,
296
300
  "http://northstar.local/contact": 2,
297
301
  "http://northstar.local/services/carpets": 3
298
302
  };
299
- var timeouts = globalUrl ? globalTimeouts : localTimeouts;
303
+ const timeouts = globalUrl ? globalTimeouts : localTimeouts;
300
304
 
301
- var timeoutFn = function (url) {
305
+ const timeoutFn = function (url) {
302
306
  return timeouts[url];
303
307
  };
304
308
 
305
- var count = 0;
309
+ let count = 0;
306
310
 
307
- var result = gen.run(options.decorate({
311
+ const result = gen.run(options.decorate({
308
312
  source: source,
309
313
  outputDir: thisOutputDir,
310
314
  timeout: timeoutFn
311
315
  }),
312
316
  function (input) {
313
- var testTimeout =
317
+ const testTimeout =
314
318
  timeouts[input.__page] ? timeouts[input.__page] : base.defaults({}).timeout;
315
319
 
316
320
  assert.equal(input.timeout, testTimeout,
@@ -327,33 +331,33 @@ describe("input-generator", function () {
327
331
  assert.ok(true);
328
332
  })
329
333
  .catch(function (err) {
330
- assert.fail("run", "fail", err.toString(), "should not");
334
+ assert.fail(`Run should not fail: ${err.toString()}`);
331
335
  });
332
336
  });
333
337
 
334
338
  it("should accept object and apply per url", function (done) {
335
- var globalTimeouts = {
339
+ const globalTimeouts = {
336
340
  "/": 1,
337
341
  "/contact": 2,
338
342
  "/services/carpets": 3,
339
343
  "__default": 4
340
344
  };
341
- var localTimeouts = {
345
+ const localTimeouts = {
342
346
  "http://northstar.local": 470,
343
347
  "http://northstar.local/contact": 480,
344
348
  "http://northstar.local/services/carpets": 490,
345
349
  "__default": 500
346
350
  };
347
- var timeouts = globalUrl ? globalTimeouts : localTimeouts;
348
- var count = 0;
351
+ const timeouts = globalUrl ? globalTimeouts : localTimeouts;
352
+ let count = 0;
349
353
 
350
- var result = gen.run(options.decorate({
354
+ const result = gen.run(options.decorate({
351
355
  source: source,
352
356
  outputDir: thisOutputDir,
353
357
  timeout: timeouts
354
358
  }),
355
359
  function (input) {
356
- var testTimeout =
360
+ const testTimeout =
357
361
  timeouts[input.__page] ? timeouts[input.__page] : timeouts.__default;
358
362
 
359
363
  assert.equal(input.timeout, testTimeout,
@@ -370,32 +374,32 @@ describe("input-generator", function () {
370
374
  assert.ok(true);
371
375
  })
372
376
  .catch(function (err) {
373
- assert.fail("run", "fail", err.toString(), "should not");
377
+ assert.fail(`Run should not fail: ${err.toString()}`);
374
378
  });
375
379
  });
376
380
 
377
381
  it("should accept object and apply per url, with missing __default",
378
382
  function (done) {
379
- var globalTimeouts = {
383
+ const globalTimeouts = {
380
384
  "/": 1,
381
385
  "/contact": 2,
382
386
  "/services/carpets": 3
383
387
  };
384
- var localTimeouts = {
388
+ const localTimeouts = {
385
389
  "http://northstar.local": 1,
386
390
  "http://northstar.local/contact": 2,
387
391
  "http://northstar.local/services/carpets": 3
388
392
  };
389
- var timeouts = globalUrl ? globalTimeouts : localTimeouts;
390
- var count = 0;
393
+ const timeouts = globalUrl ? globalTimeouts : localTimeouts;
394
+ let count = 0;
391
395
 
392
- var result = gen.run(options.decorate({
396
+ const result = gen.run(options.decorate({
393
397
  source: source,
394
398
  outputDir: thisOutputDir,
395
399
  timeout: timeouts
396
400
  }),
397
401
  function (input) {
398
- var testTimeout =
402
+ const testTimeout =
399
403
  timeouts[input.__page] ? timeouts[input.__page] : base.defaults({}).timeout;
400
404
 
401
405
  assert.equal(input.timeout, testTimeout,
@@ -412,7 +416,7 @@ describe("input-generator", function () {
412
416
  assert.ok(true);
413
417
  })
414
418
  .catch(function (err) {
415
- assert.fail("run", "fail", err.toString(), "should not");
419
+ assert.fail(`Run should not fail: ${err.toString()}`);
416
420
  })
417
421
  });
418
422
 
@@ -421,10 +425,10 @@ describe("input-generator", function () {
421
425
  describe("selector option", function () {
422
426
 
423
427
  it("should accept scalar and apply globally", function (done) {
424
- var selector = "foo";
425
- var count = 0;
428
+ const selector = "foo";
429
+ let count = 0;
426
430
 
427
- var result = gen.run(options.decorate({
431
+ const result = gen.run(options.decorate({
428
432
  source: source,
429
433
  outputDir: thisOutputDir,
430
434
  selector: selector
@@ -442,35 +446,35 @@ describe("input-generator", function () {
442
446
  assert.ok(true);
443
447
  })
444
448
  .catch(function (err) {
445
- assert.fail("run", "fail", err.toString(), "should not");
449
+ assert.fail(`Run should not fail: ${err.toString()}`);
446
450
  });
447
451
  });
448
452
 
449
453
  // requires source to contain specific urls
450
454
  it("should accept function and apply per url", function (done) {
451
- var globalSelectors = {
455
+ const globalSelectors = {
452
456
  "/": "1",
453
457
  "/contact": "2",
454
458
  "/services/carpets": "3"
455
459
  };
456
- var localSelectors = {
460
+ const localSelectors = {
457
461
  "http://northstar.local/": "1",
458
462
  "http://northstar.local/contact": "2",
459
463
  "http://northstar.local/services/carpets": "3"
460
464
  };
461
- var selectors = globalUrl ? globalSelectors : localSelectors;
462
- var selectorFn = function (url) {
465
+ const selectors = globalUrl ? globalSelectors : localSelectors;
466
+ const selectorFn = function (url) {
463
467
  return selectors[url];
464
468
  };
465
- var count = 0;
469
+ let count = 0;
466
470
 
467
- var result = gen.run(options.decorate({
471
+ const result = gen.run(options.decorate({
468
472
  source: source,
469
473
  outputDir: thisOutputDir,
470
474
  selector: selectorFn
471
475
  }),
472
476
  function (input) {
473
- var testSelector =
477
+ const testSelector =
474
478
  selectors[input.__page] ? selectors[input.__page] : base.defaults({}).selector;
475
479
 
476
480
  assert.equal(input.selector, testSelector,
@@ -487,33 +491,33 @@ describe("input-generator", function () {
487
491
  assert.ok(true);
488
492
  })
489
493
  .catch(function (err) {
490
- assert.fail("run", "fail", err.toString(), "should not");
494
+ assert.fail(`Run should not fail: ${err.toString()}`);
491
495
  });
492
496
  });
493
497
 
494
498
  it("should accept object and apply per url", function (done) {
495
- var globalSelectors = {
499
+ const globalSelectors = {
496
500
  "/": "1",
497
501
  "/contact": "2",
498
502
  "/services/carpets": "3",
499
503
  "__default": "50"
500
504
  };
501
- var localSelectors = {
505
+ const localSelectors = {
502
506
  "http://northstar.local/": "1",
503
507
  "http://northstar.local/contact": "2",
504
508
  "http://northstar.local/services/carpets": "3",
505
509
  "__default": "50"
506
510
  };
507
- var selectors = globalUrl ? globalSelectors : localSelectors;
508
- var count = 0;
511
+ const selectors = globalUrl ? globalSelectors : localSelectors;
512
+ let count = 0;
509
513
 
510
- var result = gen.run(options.decorate({
514
+ const result = gen.run(options.decorate({
511
515
  source: source,
512
516
  outputDir: thisOutputDir,
513
517
  selector: selectors
514
518
  }),
515
519
  function (input) {
516
- var testSelector =
520
+ const testSelector =
517
521
  selectors[input.__page] ? selectors[input.__page] : selectors.__default;
518
522
 
519
523
  assert.equal(input.selector, testSelector,
@@ -530,7 +534,7 @@ describe("input-generator", function () {
530
534
  assert.ok(true);
531
535
  })
532
536
  .catch(function (err) {
533
- assert.fail("run", "fail", err.toString(), "should not");
537
+ assert.fail(`Run should not fail: ${err.toString()}`);
534
538
  });
535
539
  });
536
540
 
@@ -540,10 +544,10 @@ describe("input-generator", function () {
540
544
 
541
545
  it("should accept a scalar and apply globally",
542
546
  function (done) {
543
- var useJQuery = true;
544
- var count = 0;
547
+ const useJQuery = true;
548
+ let count = 0;
545
549
 
546
- var result = gen.run(options.decorate({
550
+ const result = gen.run(options.decorate({
547
551
  source: source,
548
552
  outputDir: thisOutputDir,
549
553
  useJQuery: useJQuery
@@ -560,32 +564,32 @@ describe("input-generator", function () {
560
564
  assert.ok(true);
561
565
  })
562
566
  .catch(function (err) {
563
- assert.fail("run", "fail", err.toString(), "should not");
567
+ assert.fail(`Run should not fail: ${err.toString()}`);
564
568
  });
565
569
  });
566
570
 
567
571
  it("should accept an object and apply per url", function (done) {
568
- var globalOptions = {
572
+ const globalOptions = {
569
573
  "/": false,
570
574
  "/contact": true,
571
575
  "/services/carpets": false,
572
576
  "__default": true
573
577
  };
574
- var localOptions = {
578
+ const localOptions = {
575
579
  "http://northstar.local/": false,
576
580
  "http://northstar.local/contact": true,
577
581
  "http://northstar.local/services/carpets": false,
578
582
  "__default": true
579
583
  };
580
- var opts = globalUrl ? globalOptions : localOptions;
581
- var count = 0;
584
+ const opts = globalUrl ? globalOptions : localOptions;
585
+ let count = 0;
582
586
 
583
- var result = gen.run(options.decorate({
587
+ const result = gen.run(options.decorate({
584
588
  source: source,
585
589
  outputDir: thisOutputDir,
586
590
  useJQuery: opts
587
591
  }), function (input) {
588
- var testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
592
+ const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
589
593
 
590
594
  assert.equal(input.useJQuery, testOption,
591
595
  input.__page+":\ninput.useJQuery: "+input.useJQuery+" != testUseJQuery: "+testOption);
@@ -601,33 +605,33 @@ describe("input-generator", function () {
601
605
  assert.ok(true);
602
606
  })
603
607
  .catch(function (err) {
604
- assert.fail("run", "fail", err.toString(), "should not");
608
+ assert.fail(`Run should not fail: ${err.toString()}`);
605
609
  });
606
610
  });
607
611
 
608
612
  it("should accept a function and apply per url", function (done) {
609
- var globalOptions = {
613
+ const globalOptions = {
610
614
  "/": false,
611
615
  "/contact": true,
612
616
  "/services/carpets": false
613
617
  };
614
- var localOptions = {
618
+ const localOptions = {
615
619
  "http://northstar.local/": false,
616
620
  "http://northstar.local/contact": true,
617
621
  "http://northstar.local/services/carpets": false
618
622
  };
619
- var count = 0;
620
- var opts = globalUrl ? globalOptions : localOptions;
621
- var useJQFn = function (url) {
623
+ let count = 0;
624
+ const opts = globalUrl ? globalOptions : localOptions;
625
+ const useJQFn = function (url) {
622
626
  return opts[url];
623
627
  };
624
628
 
625
- var result = gen.run(options.decorate({
629
+ const result = gen.run(options.decorate({
626
630
  source: source,
627
631
  outputDir: thisOutputDir,
628
632
  useJQuery: useJQFn
629
633
  }), function (input) {
630
- var testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).useJQuery;
634
+ const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).useJQuery;
631
635
 
632
636
  assert.equal(input.useJQuery, testOption,
633
637
  input.__page+":\ninput.useJQuery: "+input.useJQuery+" != testUseJQuery: "+testOption);
@@ -643,7 +647,7 @@ describe("input-generator", function () {
643
647
  assert.ok(true);
644
648
  })
645
649
  .catch(function (err) {
646
- assert.fail("run", "fail", err.toString(), "should not");
650
+ assert.fail(`Run should not fail: ${err.toString()}`);
647
651
  });
648
652
  });
649
653
 
@@ -653,10 +657,10 @@ describe("input-generator", function () {
653
657
 
654
658
  it("should accept a scalar and apply globally",
655
659
  function (done) {
656
- var verbose = true;
657
- var count = 0;
660
+ const verbose = true;
661
+ let count = 0;
658
662
 
659
- var result = gen.run(options.decorate({
663
+ const result = gen.run(options.decorate({
660
664
  source: source,
661
665
  outputDir: thisOutputDir,
662
666
  verbose: verbose
@@ -673,32 +677,32 @@ describe("input-generator", function () {
673
677
  assert.ok(true);
674
678
  })
675
679
  .catch(function (err) {
676
- assert.fail("run", "fail", err.toString(), "should not");
680
+ assert.fail(`Run should not fail: ${err.toString()}`);
677
681
  });
678
682
  });
679
683
 
680
684
  it("should accept an object and apply per url", function (done) {
681
- var globalOptions = {
685
+ const globalOptions = {
682
686
  "/": false,
683
687
  "/contact": true,
684
688
  "/services/carpets": false,
685
689
  "__default": true
686
690
  };
687
- var localOptions = {
691
+ const localOptions = {
688
692
  "http://northstar.local/": false,
689
693
  "http://northstar.local/contact": true,
690
694
  "http://northstar.local/services/carpets": false,
691
695
  "__default": true
692
696
  };
693
- var opts = globalUrl ? globalOptions : localOptions;
694
- var count = 0;
697
+ const opts = globalUrl ? globalOptions : localOptions;
698
+ let count = 0;
695
699
 
696
- var result = gen.run(options.decorate({
700
+ const result = gen.run(options.decorate({
697
701
  source: source,
698
702
  outputDir: thisOutputDir,
699
703
  verbose: opts
700
704
  }), function (input) {
701
- var testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
705
+ const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
702
706
 
703
707
  assert.equal(input.verbose, testOption,
704
708
  input.__page+":\ninput.verbose: "+input.verbose+" != testVerbose: "+testOption);
@@ -714,33 +718,33 @@ describe("input-generator", function () {
714
718
  assert.ok(true);
715
719
  })
716
720
  .catch(function (err) {
717
- assert.fail("run", "fail", err.toString(), "should not");
721
+ assert.fail(`Run should not fail: ${err.toString()}`);
718
722
  });
719
723
  });
720
724
 
721
725
  it("should accept a function and apply per url", function (done) {
722
- var globalOptions = {
726
+ const globalOptions = {
723
727
  "/": false,
724
728
  "/contact": true,
725
729
  "/services/carpets": false
726
730
  };
727
- var localOptions = {
731
+ const localOptions = {
728
732
  "http://northstar.local/": false,
729
733
  "http://northstar.local/contact": true,
730
734
  "http://northstar.local/services/carpets": false
731
735
  };
732
- var count = 0;
733
- var opts = globalUrl ? globalOptions : localOptions;
734
- var useVerboseFn = function (url) {
736
+ let count = 0;
737
+ const opts = globalUrl ? globalOptions : localOptions;
738
+ const useVerboseFn = function (url) {
735
739
  return opts[url];
736
740
  };
737
741
 
738
- var result = gen.run(options.decorate({
742
+ const result = gen.run(options.decorate({
739
743
  source: source,
740
744
  outputDir: thisOutputDir,
741
745
  verbose: useVerboseFn
742
746
  }), function (input) {
743
- var testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).verbose;
747
+ const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).verbose;
744
748
 
745
749
  assert.equal(input.verbose, testOption,
746
750
  input.__page+":\ninput.verbose: "+input.verbose+" != testUseVerbose: "+testOption);
@@ -756,7 +760,7 @@ describe("input-generator", function () {
756
760
  assert.ok(true);
757
761
  })
758
762
  .catch(function (err) {
759
- assert.fail("run", "fail", err.toString(), "should not");
763
+ assert.fail(`Run should not fail: ${err.toString()}`);
760
764
  });
761
765
  });
762
766
 
@@ -765,10 +769,10 @@ describe("input-generator", function () {
765
769
  describe("phantomjsOptions option", function () {
766
770
 
767
771
  it("should accept a single string and apply globally", function (done) {
768
- var phantomjsOption = "--version";
769
- var count = 0;
772
+ const phantomjsOption = "--version";
773
+ let count = 0;
770
774
 
771
- var result = gen.run(options.decorate({
775
+ const result = gen.run(options.decorate({
772
776
  source: source,
773
777
  outputDir: thisOutputDir,
774
778
  phantomjsOptions: phantomjsOption
@@ -788,15 +792,15 @@ describe("input-generator", function () {
788
792
  assert.ok(true);
789
793
  })
790
794
  .catch(function (err) {
791
- assert.fail("run", "fail", err.toString(), "should not");
795
+ assert.fail(`Run should not fail: ${err.toString()}`);
792
796
  });
793
797
  });
794
798
 
795
799
  it("should accept a single array and apply globally", function (done) {
796
- var phantomjsOption = ["--version", "--help"];
797
- var count = 0;
800
+ const phantomjsOption = ["--version", "--help"];
801
+ let count = 0;
798
802
 
799
- var result = gen.run(options.decorate({
803
+ const result = gen.run(options.decorate({
800
804
  source: source,
801
805
  outputDir: thisOutputDir,
802
806
  phantomjsOptions: phantomjsOption
@@ -820,36 +824,36 @@ describe("input-generator", function () {
820
824
  assert.ok(true);
821
825
  })
822
826
  .catch(function (err) {
823
- assert.fail("run", "fail", err.toString(), "should not");
827
+ assert.fail(`Run should not fail: ${err.toString()}`);
824
828
  });
825
829
  });
826
830
 
827
831
  it("should accept an object and apply per url", function (done) {
828
- var phantomjsOption1 = "--version",
832
+ const phantomjsOption1 = "--version",
829
833
  phantomjsOption2 = ["--help"],
830
834
  phantomjsOption3 = ["--another-option=somevalue", "--some-other-option=someother"];
831
835
 
832
- var globalOptions = {
836
+ const globalOptions = {
833
837
  "/": phantomjsOption1,
834
838
  "/contact": phantomjsOption2,
835
839
  "/services/carpets": phantomjsOption3,
836
840
  "__default": ""
837
841
  };
838
- var localOptions = {
842
+ const localOptions = {
839
843
  "http://northstar.local/": phantomjsOption1,
840
844
  "http://northstar.local/contact": phantomjsOption2,
841
845
  "http://northstar.local/services/carpets": phantomjsOption3,
842
846
  "__default": ""
843
847
  };
844
- var opts = globalUrl ? globalOptions : localOptions;
845
- var count = 0;
848
+ const opts = globalUrl ? globalOptions : localOptions;
849
+ let count = 0;
846
850
 
847
- var result = gen.run(options.decorate({
851
+ const result = gen.run(options.decorate({
848
852
  source: source,
849
853
  outputDir: thisOutputDir,
850
854
  phantomjsOptions: opts
851
855
  }), function (input) {
852
- var testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
856
+ const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
853
857
 
854
858
  assert.deepEqual(input.phantomjsOptions, testOption,
855
859
  input.__page+":\ninput.phantomjsOptions: "+input.phantomjsOptions+" != testPhantomJSOption: "+testOption);
@@ -865,37 +869,37 @@ describe("input-generator", function () {
865
869
  assert.ok(true);
866
870
  })
867
871
  .catch(function (err) {
868
- assert.fail("run", "fail", err.toString(), "should not");
872
+ assert.fail(`Run should not fail: ${err.toString()}`);
869
873
  });
870
874
  });
871
875
 
872
876
  it("should accept a function and apply per url", function (done) {
873
- var phantomjsOption1 = "--version",
877
+ const phantomjsOption1 = "--version",
874
878
  phantomjsOption2 = ["--help"],
875
879
  phantomjsOption3 = ["--another-option=somevalue", "--some-other-option=someother"];
876
880
 
877
- var globalOptions = {
881
+ const globalOptions = {
878
882
  "/": phantomjsOption1,
879
883
  "/contact": phantomjsOption2,
880
884
  "/services/carpets": phantomjsOption3
881
885
  };
882
- var localOptions = {
886
+ const localOptions = {
883
887
  "http://northstar.local/": phantomjsOption1,
884
888
  "http://northstar.local/contact": phantomjsOption2,
885
889
  "http://northstar.local/services/carpets": phantomjsOption3
886
890
  };
887
- var opts = globalUrl ? globalOptions : localOptions;
888
- var count = 0;
889
- var phantomjsFn = function (url) {
891
+ const opts = globalUrl ? globalOptions : localOptions;
892
+ let count = 0;
893
+ const phantomjsFn = function (url) {
890
894
  return opts[url];
891
895
  };
892
896
 
893
- var result = gen.run(options.decorate({
897
+ const result = gen.run(options.decorate({
894
898
  source: source,
895
899
  outputDir: thisOutputDir,
896
900
  phantomjsOptions: phantomjsFn
897
901
  }), function (input) {
898
- var testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).phantomjsOptions;
902
+ const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).phantomjsOptions;
899
903
 
900
904
  assert.deepEqual(input.phantomjsOptions, testOption,
901
905
  input.__page+":\ninput.phantomjsOptions: "+input.phantomjsOptions+" != testPhantomJSOption: "+testOption);
@@ -911,7 +915,7 @@ describe("input-generator", function () {
911
915
  assert.ok(true);
912
916
  })
913
917
  .catch(function (err) {
914
- assert.fail("run", "fail", err.toString(), "should not");
918
+ assert.fail(`Run should not fail: ${err.toString()}`);
915
919
  });
916
920
  });
917
921
 
@@ -920,17 +924,17 @@ describe("input-generator", function () {
920
924
  describe("url behavior", function () {
921
925
 
922
926
  it("should replace the default hostname in results", function (done) {
923
- var hostname = "foo";
924
- var count = 0;
927
+ const hostname = "foo";
928
+ let count = 0;
925
929
 
926
- var result = gen.run(options.decorate({
930
+ const result = gen.run(options.decorate({
927
931
  source: source,
928
932
  outputDir: thisOutputDir,
929
933
  hostname: hostname
930
934
  }),
931
935
  function (input) {
932
- var re = new RegExp("http://("+hostname+")/");
933
- var match = re.exec(input.url);
936
+ const re = new RegExp(`http://(${hostname})/`);
937
+ const match = re.exec(input.url);
934
938
  if (globalUrl) {
935
939
  assert.equal(match[1], hostname);
936
940
  } else {
@@ -947,22 +951,22 @@ describe("input-generator", function () {
947
951
  assert.ok(true);
948
952
  })
949
953
  .catch(function (err) {
950
- assert.fail("run", "fail", err.toString(), "should not");
954
+ assert.fail(`Run should not fail: ${err.toString()}`);
951
955
  });
952
956
  });
953
957
 
954
958
  it("should replace the default protocol in results", function (done) {
955
- var proto = "file";
956
- var count = 0;
959
+ const proto = "file";
960
+ let count = 0;
957
961
 
958
- var result = gen.run(options.decorate({
962
+ const result = gen.run(options.decorate({
959
963
  source: source,
960
964
  outputDir: thisOutputDir,
961
965
  protocol: proto
962
966
  }),
963
967
  function (input) {
964
- var re = new RegExp("^("+proto+")://");
965
- var match = re.exec(input.url);
968
+ const re = new RegExp(`^(${proto})://`);
969
+ const match = re.exec(input.url);
966
970
  if (globalUrl) {
967
971
  assert.equal(match[1], proto);
968
972
  } else {
@@ -979,23 +983,23 @@ describe("input-generator", function () {
979
983
  assert.ok(true);
980
984
  })
981
985
  .catch(function (err) {
982
- assert.fail("run", "fail", err.toString(), "should not");
986
+ assert.fail(`Run should not fail: ${err.toString()}`);
983
987
  });
984
988
  });
985
989
 
986
990
  it("should contain a port in the url if one is specified",
987
991
  function (done) {
988
- var port = 8080;
989
- var count = 0;
992
+ const port = 8080;
993
+ let count = 0;
990
994
 
991
- var result = gen.run(options.decorate({
995
+ const result = gen.run(options.decorate({
992
996
  source: source,
993
997
  outputDir: thisOutputDir,
994
998
  port: port
995
999
  }),
996
1000
  function (input) {
997
- var re = new RegExp("^http://localhost\\:("+port+")/");
998
- var match = re.exec(input.url);
1001
+ const re = new RegExp(`^http://localhost\\:(${port})/`);
1002
+ const match = re.exec(input.url);
999
1003
  if (globalUrl) {
1000
1004
  assert.equal(match[1], port);
1001
1005
  } else {
@@ -1012,27 +1016,27 @@ describe("input-generator", function () {
1012
1016
  assert.ok(true);
1013
1017
  })
1014
1018
  .catch(function (err) {
1015
- assert.fail("run", "fail", err.toString(), "should not");
1019
+ assert.fail(`Run should not fail: ${err.toString()}`);
1016
1020
  });
1017
1021
  });
1018
1022
 
1019
1023
  it("should contain an auth in the url if one is specified",
1020
1024
  function (done) {
1021
- var auth = "user:pass";
1022
- var count = 0;
1025
+ const auth = "user:pass";
1026
+ let count = 0;
1023
1027
 
1024
- var result = gen.run(options.decorate({
1028
+ const result = gen.run(options.decorate({
1025
1029
  source: source,
1026
1030
  outputDir: thisOutputDir,
1027
1031
  auth: auth
1028
1032
  }),
1029
1033
  function (input) {
1030
- var re = new RegExp("^http://("+auth+")@localhost/");
1031
- var match = re.exec(input.url);
1034
+ const re = new RegExp(`^http://(${auth})@localhost/`);
1035
+ const match = re.exec(input.url);
1032
1036
  if (globalUrl) {
1033
1037
  assert.equal(match[1], auth);
1034
1038
  } else {
1035
- assert.equal(match ===null, true);
1039
+ assert.equal(match === null, true);
1036
1040
  }
1037
1041
  count++;
1038
1042
  if (count === urls) {
@@ -1045,51 +1049,56 @@ describe("input-generator", function () {
1045
1049
  assert.ok(true);
1046
1050
  })
1047
1051
  .catch(function (err) {
1048
- assert.fail("run", "fail", err.toString(), "should not");
1052
+ assert.fail(`Run should not fail: ${err.toString()}`);
1049
1053
  });
1050
1054
  });
1051
1055
 
1052
1056
  if (remote) {
1053
- it("should process remote source urls", function (done) {
1054
- var count = 0;
1055
-
1056
- var result = gen.run(options.decorate({
1057
- source: remote,
1058
- outputDir: thisOutputDir,
1059
- _abort: function (err) {
1060
- assert.fail(false, !!err, remote + " should not have aborted: " + err.toString(), ",");
1061
- }
1062
- }), function (input) {
1063
- assert(true, common.isUrl(input.url));
1064
- count++;
1065
- if (count === urls) {
1066
- done();
1067
- }
1068
- });
1057
+ remote.forEach(remoteUrl => {
1058
+ it(`should process remote source url ${remoteUrl}`, function (done) {
1059
+ this.timeout(5000);
1060
+ let count = 0;
1069
1061
 
1070
- result
1071
- .then(function () {
1072
- assert.ok(true);
1073
- })
1074
- .catch(function (err) {
1075
- assert.fail("run", "fail", err.toString(), "should not");
1062
+ const result = gen.run(options.decorate({
1063
+ source: remoteUrl,
1064
+ outputDir: thisOutputDir,
1065
+ _abort: function (err) {
1066
+ assert.fail(`${remoteUrl} should not have aborted: ${err.toString()}`);
1067
+ }
1068
+ }), function (input) {
1069
+ assert(true, common.isUrl(input.url));
1070
+ count++;
1071
+ if (count === urls) {
1072
+ done();
1073
+ }
1076
1074
  });
1075
+
1076
+ result
1077
+ .then(function () {
1078
+ assert.ok(true);
1079
+ })
1080
+ .catch(function (err) {
1081
+ assert.fail(`Run should not fail: ${err.toString()}`);
1082
+ });
1083
+ });
1077
1084
  });
1078
1085
  }
1079
1086
 
1080
1087
  if (bad) {
1081
- bad.forEach(function (badSource) {
1082
- it("should handle bad source "+badSource, function (done) {
1088
+ bad.forEach(badSource => {
1089
+ it(`should handle bad source ${badSource}`, function (done) {
1090
+ this.timeout(10000);
1083
1091
  gen.run(options.decorate({
1084
1092
  source: badSource,
1085
1093
  outputDir: thisOutputDir,
1086
1094
  _abort: function (err) {
1087
- assert.equal(true, !!err, badSource + " should have aborted with error");
1095
+ // console.log(`@@@ ${badSource} should have aborted with error`);
1096
+ assert.equal(true, !!err, `${badSource} should have aborted with error`);
1088
1097
  done();
1089
1098
  }
1090
1099
  }), function () {
1091
1100
  //console.log("@@@ bad input:\n"+require("util").inspect(input));
1092
- assert.fail(false, true, " input handler was called unexpectedly for badSource "+badSource, ",");
1101
+ assert.fail(`Input handler was called unexpectedly for badSource: ${badSource}`);
1093
1102
  done(true);
1094
1103
  });
1095
1104
  });
@@ -1100,10 +1109,10 @@ describe("input-generator", function () {
1100
1109
  describe("checkInterval option", function () {
1101
1110
 
1102
1111
  it("should replace the default checkInterval globally", function (done) {
1103
- var checkInterval = 1;
1104
- var count = 0;
1112
+ const checkInterval = 1;
1113
+ let count = 0;
1105
1114
 
1106
- var result = gen.run(options.decorate({
1115
+ const result = gen.run(options.decorate({
1107
1116
  source: source,
1108
1117
  outputDir: thisOutputDir,
1109
1118
  checkInterval: checkInterval
@@ -1120,7 +1129,7 @@ describe("input-generator", function () {
1120
1129
  assert.ok(true);
1121
1130
  })
1122
1131
  .catch(function (err) {
1123
- assert.fail("run", "fail", err.toString(), "should not");
1132
+ assert.fail(`Run should not fail: ${err.toString()}`);
1124
1133
  });
1125
1134
  });
1126
1135
 
@@ -1130,15 +1139,15 @@ describe("input-generator", function () {
1130
1139
 
1131
1140
  it("should contain the snapshot directory in output outfile spec",
1132
1141
  function (done) {
1133
- var snapshotDir = "foo";
1134
- var count = 0;
1142
+ const snapshotDir = "foo";
1143
+ let count = 0;
1135
1144
 
1136
- var result = gen.run(options.decorate({
1145
+ const result = gen.run(options.decorate({
1137
1146
  source: source,
1138
1147
  outputDir: path.join(thisOutputDir, snapshotDir)
1139
1148
  }), function (input) {
1140
- var re = new RegExp("\\"+path.sep+"("+snapshotDir+")"+"\\"+path.sep);
1141
- var match = re.exec(input.outputFile);
1149
+ const re = new RegExp("\\"+path.sep+"("+snapshotDir+")"+"\\"+path.sep);
1150
+ const match = re.exec(input.outputFile);
1142
1151
  assert.equal(match[1], snapshotDir);
1143
1152
  count++;
1144
1153
  if (count === urls) {
@@ -1151,38 +1160,35 @@ describe("input-generator", function () {
1151
1160
  assert.ok(true);
1152
1161
  })
1153
1162
  .catch(function (err) {
1154
- assert.fail("run", "fail", err.toString(), "should not");
1163
+ assert.fail(`Run should not fail: ${err.toString()}`);
1155
1164
  });
1156
1165
  });
1157
1166
 
1158
1167
  // requires inputFile to contain specific urls
1159
1168
  it("should contain the page structure in the output file spec",
1160
1169
  function (done) {
1161
- var snapshotDir = "foo";
1162
- var pages = {
1170
+ const snapshotDir = "foo";
1171
+ const pages = !globalUrl ? {
1172
+ "http://northstar.local/": "/",
1173
+ "http://northstar.local/contact": "/contact",
1174
+ "http://northstar.local/services/carpets": "/services/carpets",
1175
+ "http://northstar.local/services/test?arg=one": "/services/test",
1176
+ "https://northstar.local/services/#hash": "/services"
1177
+ } : {
1163
1178
  "/": "/",
1164
1179
  "/contact": "/contact",
1165
1180
  "/services/carpets": "/services/carpets",
1166
1181
  "/services/test?arg=one": "/services/test",
1167
1182
  "/services/#hash": "/services"
1168
1183
  };
1169
- if (!globalUrl) {
1170
- pages = {
1171
- "http://northstar.local/": "/",
1172
- "http://northstar.local/contact": "/contact",
1173
- "http://northstar.local/services/carpets": "/services/carpets",
1174
- "http://northstar.local/services/test?arg=one": "/services/test",
1175
- "https://northstar.local/services/#hash": "/services"
1176
- };
1177
- }
1178
- var count = 0;
1184
+ let count = 0;
1179
1185
 
1180
- var result = gen.run(options.decorate({
1186
+ const result = gen.run(options.decorate({
1181
1187
  source: source,
1182
1188
  outputDir: path.join(thisOutputDir, snapshotDir)
1183
1189
  }), function (input) {
1184
- var re = new RegExp("("+snapshotDir+")("+urlToPathRe(pages[input.__page])+")");
1185
- var match = re.exec(input.outputFile);
1190
+ const re = new RegExp("("+snapshotDir+")("+urlToPathRe(pages[input.__page])+")");
1191
+ const match = re.exec(input.outputFile);
1186
1192
 
1187
1193
  assert.equal(true, match[1] === snapshotDir && match[2] === urlToPath(pages[input.__page]));
1188
1194
 
@@ -1197,7 +1203,7 @@ describe("input-generator", function () {
1197
1203
  assert.ok(true);
1198
1204
  })
1199
1205
  .catch(function (err) {
1200
- assert.fail("run", "fail", err.toString(), "should not");
1206
+ assert.fail(`Run should not fail: ${err.toString()}`);
1201
1207
  });
1202
1208
  });
1203
1209
 
@@ -1206,35 +1212,32 @@ describe("input-generator", function () {
1206
1212
  describe("outputPath option", function () {
1207
1213
  it("should lookup an outputPath (per page from a function) if one is specified",
1208
1214
  function (done) {
1209
- var argOne = "/services/test/arg/one";
1210
- var hash = "/services/hash";
1211
- var pages = {
1215
+ const argOne = "/services/test/arg/one";
1216
+ const hash = "/services/hash";
1217
+ const pages = !globalUrl ? {
1218
+ "http://northstar.local/": "/",
1219
+ "http://northstar.local/contact": "/contact",
1220
+ "http://northstar.local/services/carpets": "/services/carpets",
1221
+ "http://northstar.local/services/test?arg=one": argOne,
1222
+ "https://northstar.local/services/#hash": hash
1223
+ } : {
1212
1224
  "/": "/",
1213
1225
  "/contact": "/contact",
1214
1226
  "/services/carpets": "/services/carpets",
1215
1227
  "/services/test?arg=one": argOne,
1216
1228
  "/services/#hash": hash
1217
1229
  };
1218
- if (!globalUrl) {
1219
- pages = {
1220
- "http://northstar.local/": "/",
1221
- "http://northstar.local/contact": "/contact",
1222
- "http://northstar.local/services/carpets": "/services/carpets",
1223
- "http://northstar.local/services/test?arg=one": argOne,
1224
- "https://northstar.local/services/#hash": hash
1225
- };
1226
- }
1227
- var count = 0;
1230
+ let count = 0;
1228
1231
 
1229
- var result = gen.run(options.decorate({
1232
+ const result = gen.run(options.decorate({
1230
1233
  source: source,
1231
1234
  outputPath: function (p) {
1232
1235
  return pages[p];
1233
1236
  },
1234
1237
  outputDir: thisOutputDir
1235
1238
  }), function (input) {
1236
- var re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1237
- var match = re.exec(input.outputFile);
1239
+ const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1240
+ const match = re.exec(input.outputFile);
1238
1241
  assert.equal(match[1], urlToPath(pages[input.__page]));
1239
1242
  count++;
1240
1243
  if (count === urls) {
@@ -1247,44 +1250,40 @@ describe("input-generator", function () {
1247
1250
  assert.ok(true);
1248
1251
  })
1249
1252
  .catch(function (err) {
1250
- assert.fail("run", "fail", err.toString(), "should not");
1253
+ assert.fail(`Run should not fail: ${err.toString()}`);
1251
1254
  });
1252
1255
  });
1253
1256
 
1254
1257
  it("should lookup an outputPath (from a hash) and find it in the outputFile spec",
1255
1258
  function (done) {
1256
- var argOne = "/services/test/arg/one";
1257
- var hash = "/services/hash";
1258
- var outputPath = { "/services/test?arg=one": argOne, "/services/#hash": hash };
1259
- var pages = {
1259
+ const argOne = "/services/test/arg/one";
1260
+ const hash = "/services/hash";
1261
+ const outputPath = !globalUrl ? {
1262
+ "http://northstar.local/services/test?arg=one": argOne,
1263
+ "https://northstar.local/services/#hash": hash
1264
+ } : { "/services/test?arg=one": argOne, "/services/#hash": hash };
1265
+ const pages = !globalUrl ? {
1266
+ "http://northstar.local/": "/",
1267
+ "http://northstar.local/contact": "/contact",
1268
+ "http://northstar.local/services/carpets": "/services/carpets",
1269
+ "http://northstar.local/services/test?arg=one": argOne,
1270
+ "https://northstar.local/services/#hash": hash
1271
+ } : {
1260
1272
  "/": "/",
1261
1273
  "/contact": "/contact",
1262
1274
  "/services/carpets": "/services/carpets",
1263
1275
  "/services/test?arg=one": argOne,
1264
1276
  "/services/#hash": hash
1265
1277
  };
1266
- if (!globalUrl) {
1267
- outputPath = {
1268
- "http://northstar.local/services/test?arg=one": argOne,
1269
- "https://northstar.local/services/#hash": hash
1270
- };
1271
- pages = {
1272
- "http://northstar.local/": "/",
1273
- "http://northstar.local/contact": "/contact",
1274
- "http://northstar.local/services/carpets": "/services/carpets",
1275
- "http://northstar.local/services/test?arg=one": argOne,
1276
- "https://northstar.local/services/#hash": hash
1277
- };
1278
- }
1279
- var count = 0;
1278
+ let count = 0;
1280
1279
 
1281
- var result = gen.run(options.decorate({
1280
+ const result = gen.run(options.decorate({
1282
1281
  source: source,
1283
1282
  outputDir: thisOutputDir,
1284
1283
  outputPath: outputPath
1285
1284
  }), function (input) {
1286
- var re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1287
- var match = re.exec(input.outputFile);
1285
+ const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1286
+ const match = re.exec(input.outputFile);
1288
1287
  assert.equal(match[1], urlToPath(pages[input.__page]));
1289
1288
  count++;
1290
1289
  if (count === urls) {
@@ -1297,16 +1296,24 @@ describe("input-generator", function () {
1297
1296
  assert.ok(true);
1298
1297
  })
1299
1298
  .catch(function (err) {
1300
- assert.fail("run", "fail", err.toString(), "should not");
1299
+ assert.fail(`Run should not fail: ${err.toString()}`);
1301
1300
  });
1302
1301
  });
1303
1302
 
1304
1303
  it("should return false if a snapshot can't be created",
1305
1304
  function (done) {
1306
- var aborted = false;
1307
- var argOne = "/services/test/arg/one";
1308
- var hash = "/services/hash";
1309
- var pages = {
1305
+ let aborted = false;
1306
+ let count = 0;
1307
+ const argOne = "/services/test/arg/one";
1308
+ const hash = "/services/hash";
1309
+ const pages = !globalUrl ? {
1310
+ // this causes the problem
1311
+ //"http://northstar.local/": "/",
1312
+ "http://northstar.local/contact": "/contact",
1313
+ "http://northstar.local/services/carpets": "/services/carpets",
1314
+ "http://northstar.local/services/test?arg=one": argOne,
1315
+ "https://northstar.local/services/#hash": hash
1316
+ } : {
1310
1317
  // this causes the problem
1311
1318
  //"/": "/",
1312
1319
  "/contact": "/contact",
@@ -1314,17 +1321,6 @@ describe("input-generator", function () {
1314
1321
  "/services/test?arg=one": argOne,
1315
1322
  "/services/#hash": hash
1316
1323
  };
1317
- if (!globalUrl) {
1318
- pages = {
1319
- // this causes the problem
1320
- //"http://northstar.local/": "/",
1321
- "http://northstar.local/contact": "/contact",
1322
- "http://northstar.local/services/carpets": "/services/carpets",
1323
- "http://northstar.local/services/test?arg=one": argOne,
1324
- "https://northstar.local/services/#hash": hash
1325
- };
1326
- }
1327
- var count = 0;
1328
1324
 
1329
1325
  gen.run(options.decorate({
1330
1326
  source: source,
@@ -1339,8 +1335,8 @@ describe("input-generator", function () {
1339
1335
  }
1340
1336
  }), function (input) {
1341
1337
  if (!aborted) {
1342
- var re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1343
- var match = re.exec(input.outputFile);
1338
+ const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
1339
+ const match = re.exec(input.outputFile);
1344
1340
  assert.equal(match[1], urlToPath(pages[input.__page]));
1345
1341
  count++;
1346
1342
  if (count === (urls-1)) {