html-snapshots 1.3.2 → 1.5.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/lib/common/index.js +57 -3
- package/lib/common/sitemap/sitemap-collection.js +3 -2
- package/lib/common/sitemap/sitemap-index.js +1 -4
- package/lib/common/sitemap/sitemap.js +15 -13
- package/lib/html-snapshots.js +5 -6
- package/lib/input-generators/_base.js +5 -5
- package/package.json +5 -6
- package/.c8rc.json +0 -5
- package/.eslintignore +0 -5
- package/.eslintrc.json +0 -16
- package/.github/issue_template.md +0 -16
- package/.github/workflows/verify.yml +0 -32
- package/docs/example-heroku-redis.md +0 -43
- package/docs/notes.md +0 -42
- package/examples/README.md +0 -149
- package/examples/custom/README.md +0 -22
- package/examples/custom/myFilter.js +0 -22
- package/examples/custom/package-lock.json +0 -2804
- package/examples/custom/package.json +0 -12
- package/examples/custom/snapshot.js +0 -28
- package/examples/debug-phantomjs/README.md +0 -38
- package/examples/debug-phantomjs/package-lock.json +0 -2922
- package/examples/debug-phantomjs/package.json +0 -12
- package/examples/debug-phantomjs/snapshot.js +0 -60
- package/examples/debug-puppeteer/README.md +0 -18
- package/examples/debug-puppeteer/package-lock.json +0 -2804
- package/examples/debug-puppeteer/package.json +0 -12
- package/examples/debug-puppeteer/snapshot.js +0 -30
- package/examples/html5rocks/README.md +0 -22
- package/examples/html5rocks/package-lock.json +0 -3218
- package/examples/html5rocks/package.json +0 -12
- package/examples/html5rocks/snapshot.js +0 -59
- package/examples/process-limit/README.md +0 -24
- package/examples/process-limit/package-lock.json +0 -2830
- package/examples/process-limit/package.json +0 -12
- package/examples/process-limit/snapshot.js +0 -30
- package/examples/simple-promise/README.md +0 -20
- package/examples/simple-promise/package-lock.json +0 -2830
- package/examples/simple-promise/package.json +0 -12
- package/examples/simple-promise/snapshot.js +0 -30
- package/examples/sitemap-index/README.md +0 -20
- package/examples/sitemap-index/package-lock.json +0 -2830
- package/examples/sitemap-index/package.json +0 -12
- package/examples/sitemap-index/snapshot.js +0 -34
- package/examples/verbose/README.md +0 -22
- package/examples/verbose/package-lock.json +0 -2805
- package/examples/verbose/package.json +0 -12
- package/examples/verbose/snapshot.js +0 -34
- package/test/helpers/options.js +0 -55
- package/test/helpers/result.js +0 -32
- package/test/helpers/sitemap.js +0 -130
- package/test/mocha/async/test.js +0 -416
- package/test/mocha/browsers/puppeteer.js +0 -129
- package/test/mocha/browsers/server/index.html +0 -9
- package/test/mocha/browsers/test.js +0 -11
- package/test/mocha/common/helpers.js +0 -87
- package/test/mocha/common/test.js +0 -188
- package/test/mocha/html-snapshots/basics.js +0 -88
- package/test/mocha/html-snapshots/myFilter.js +0 -10
- package/test/mocha/html-snapshots/phantomjs-options.js +0 -156
- package/test/mocha/html-snapshots/process-limit.js +0 -156
- package/test/mocha/html-snapshots/puppeteer.js +0 -47
- package/test/mocha/html-snapshots/robots.js +0 -194
- package/test/mocha/html-snapshots/server/contact/index.html +0 -57
- package/test/mocha/html-snapshots/server/favicon.ico +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.eot +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.svg +0 -220
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.ttf +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.woff +0 -0
- package/test/mocha/html-snapshots/server/images/ajax-loader.gif +0 -0
- package/test/mocha/html-snapshots/server/images/art1.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpet.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet1.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet1_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet2.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet2_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet3.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet3_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet4.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet4_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/floor.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/bullets.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/left-arrow-small.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/left-arrow.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/loading.gif +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/mask-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/pause-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/right-arrow-small.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/right-arrow.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/rotator-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/timer-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/certification.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/cleantrust.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/institute.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite-s1a48fdbd81.png +0 -0
- package/test/mocha/html-snapshots/server/images/logo-300.png +0 -0
- package/test/mocha/html-snapshots/server/images/slider1-lg.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/slider1.jpg +0 -0
- package/test/mocha/html-snapshots/server/index.css +0 -1
- package/test/mocha/html-snapshots/server/index.html +0 -57
- package/test/mocha/html-snapshots/server/nojq/index.html +0 -46
- package/test/mocha/html-snapshots/server/pjsopts/index.html +0 -55
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress/category-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress/post-sitemap.xml +0 -27
- package/test/mocha/html-snapshots/server/public/wordpress/post_tag-sitemap.xml +0 -17
- package/test/mocha/html-snapshots/server/public/wordpress/product-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress-2/category-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress-2/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress-2/post-sitemap.xml +0 -27
- package/test/mocha/html-snapshots/server/public/wordpress-2/post_tag-sitemap.xml +0 -17
- package/test/mocha/html-snapshots/server/public/wordpress-2/product-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/require.js +0 -1
- package/test/mocha/html-snapshots/server/services/carpets/index.html +0 -57
- package/test/mocha/html-snapshots/server/test_robots.txt +0 -13
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +0 -15
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +0 -22
- package/test/mocha/html-snapshots/server/test_sitemap_index-2.xml +0 -25
- package/test/mocha/html-snapshots/server/test_sitemap_index-3.xml +0 -25
- package/test/mocha/html-snapshots/server/test_sitemap_index.xml +0 -25
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/custom-validity.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/modernizr-custom.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/mousepress.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/polyfiller.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/canvas2png.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/flashcanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/flashcanvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/proxy.php +0 -73
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/save.php +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/canvas2png.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flash10canvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flash9canvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flashcanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/proxy.php +0 -73
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/save.php +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/1.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/10.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/11.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/12.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/13.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/14.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/15.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/16.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/17.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/18.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/19.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/2.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/20.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/21.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/22.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/23.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/24.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/25.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/26.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/27.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/3.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/4.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/5.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/59.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/6.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/7.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/8.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/9.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/details.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/dom-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/es5.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/excanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-core.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-datalist.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-message.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-native-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-number-date-api.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-number-date-ui.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-shim-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/geolocation.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ar.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ch-ZN.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-de.txt +0 -33
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-el.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-en.txt +0 -34
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-es.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-fr.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-he.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-hi.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-hu.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-it.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ja.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-nl.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-pt-PT.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ru.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-sv.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/json-storage.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/license.txt +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/player.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/readme.html +0 -87
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-core.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-jaris.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-native-fix.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-swf.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-yt.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/details-arrows.png +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/forms.png +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/polyfill-loader.gif +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/shim.css +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/JarisFLVPlayer.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/jwwebshims.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/localStorage.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/track-ui.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/track.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/plugins/cload.js +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/plugins/modernizr.js +0 -4
- package/test/mocha/html-snapshots/server/vendor/js/plugins/oldie.js +0 -74
- package/test/mocha/html-snapshots/sitemap-index.js +0 -140
- package/test/mocha/html-snapshots/sitemap.js +0 -104
- package/test/mocha/html-snapshots/snapshot-scripts.js +0 -206
- package/test/mocha/html-snapshots/test.js +0 -105
- package/test/mocha/html-snapshots/test_robots.txt +0 -13
- package/test/mocha/html-snapshots/test_sitemap.xml +0 -22
- package/test/mocha/html-snapshots/use-jquery.js +0 -144
- package/test/mocha/html-snapshots/utils.js +0 -200
- package/test/mocha/input-generators/server/public/wordpress/category-sitemap.xml +0 -13
- package/test/mocha/input-generators/server/public/wordpress/page-sitemap.xml +0 -16
- package/test/mocha/input-generators/server/public/wordpress/post-sitemap.xml +0 -55
- package/test/mocha/input-generators/server/public/wordpress/post_tag-sitemap.xml +0 -25
- package/test/mocha/input-generators/server/public/wordpress/product-sitemap.xml +0 -13
- package/test/mocha/input-generators/server/test_robots.txt +0 -15
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -11
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +0 -17
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +0 -17
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +0 -18
- package/test/mocha/input-generators/server/test_sitemap.xml +0 -34
- package/test/mocha/input-generators/server/test_sitemap.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_bad.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_index.xml +0 -25
- package/test/mocha/input-generators/server/test_sitemap_index.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +0 -3
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +0 -2
- package/test/mocha/input-generators/sitemap-index.js +0 -87
- package/test/mocha/input-generators/sitemap.js +0 -320
- package/test/mocha/input-generators/test.js +0 -1447
- package/test/mocha/input-generators/test_line.txt +0 -5
- package/test/mocha/input-generators/test_robots.txt +0 -15
- package/test/mocha/input-generators/test_robots_bad.txt +0 -11
- package/test/mocha/input-generators/test_robots_sitemap.txt +0 -17
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +0 -17
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +0 -18
- package/test/mocha/input-generators/test_sitemap.xml +0 -34
- package/test/mocha/input-generators/test_sitemap.xml.gz +0 -0
- package/test/mocha/input-generators/test_sitemap_bad.xml.gz +0 -0
- package/test/mocha/input-generators/test_sitemap_index.xml +0 -25
- package/test/mocha/input-generators/test_sitemap_index.xml.gz +0 -0
- package/test/server/index.js +0 -32
|
@@ -1,1447 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* General input generator tests.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global describe, it, before */
|
|
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
|
-
|
|
16
|
-
describe("input-generator", function () {
|
|
17
|
-
|
|
18
|
-
before(function () {
|
|
19
|
-
server.start(path.join(__dirname, "./server"), port);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("null", function () {
|
|
23
|
-
it("'index' should return a null generator", function () {
|
|
24
|
-
assert.equal(true, factory.isNull(factory.create("index")));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("'_common' should return a null generator", function () {
|
|
28
|
-
assert.equal(true, factory.isNull(factory.create("_base")));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("'_any' should return a null generator", function () {
|
|
32
|
-
assert.equal(true, factory.isNull(factory.create("_any")));
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("'notvalid' should return a null generator", function () {
|
|
36
|
-
assert.equal(true, factory.isNull(factory.create("notvalid")));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("no input should return a null generator", function () {
|
|
40
|
-
assert.equal(true, factory.isNull(factory.create()));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("should have a run method", function () {
|
|
44
|
-
assert.equal(true, typeof factory.create().run === 'function');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("run method should return an empty array", function () {
|
|
48
|
-
assert.equal(true, factory.create().run().length === 0);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const thisOutputDir = path.join(__dirname, "snapshots");
|
|
53
|
-
|
|
54
|
-
const inputGenerators = [
|
|
55
|
-
{
|
|
56
|
-
name: "robots",
|
|
57
|
-
input: factory.create("robots"),
|
|
58
|
-
source: path.join(__dirname, "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
|
-
],
|
|
64
|
-
bad: [
|
|
65
|
-
path.join(__dirname, "test_robots_bad.txt"),
|
|
66
|
-
`http://localhost:${port}/test_robots_bad.txt`,
|
|
67
|
-
`http://localhost:${port}/test_robots_sitemap_bad.txt`
|
|
68
|
-
],
|
|
69
|
-
urls: 5
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "textfile",
|
|
73
|
-
input: factory.create("textfile"),
|
|
74
|
-
source: path.join(__dirname, "test_line.txt"),
|
|
75
|
-
urls: 5
|
|
76
|
-
},
|
|
77
|
-
{ name: "array", input: factory.create("array"), source:
|
|
78
|
-
// same as urls in sitemap
|
|
79
|
-
[
|
|
80
|
-
"http://northstar.local/",
|
|
81
|
-
"http://northstar.local/contact",
|
|
82
|
-
"http://northstar.local/services/carpets",
|
|
83
|
-
"http://northstar.local/services/test?arg=one",
|
|
84
|
-
"https://northstar.local/services/#hash"
|
|
85
|
-
],
|
|
86
|
-
urls: 5
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "sitemap",
|
|
90
|
-
input: factory.create("sitemap"),
|
|
91
|
-
source: path.join(__dirname, "test_sitemap.xml"),
|
|
92
|
-
remote: [`http://localhost:${port}/test_sitemap.xml`],
|
|
93
|
-
urls: 5
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: "sitemap-gzip",
|
|
97
|
-
input: factory.create("sitemap"),
|
|
98
|
-
source: path.join(__dirname, "test_sitemap.xml.gz"),
|
|
99
|
-
remote: [`http://localhost:${port}/test_sitemap.xml.gz`],
|
|
100
|
-
bad: [
|
|
101
|
-
path.join(__dirname, "test_sitemap_bad.xml.gz"),
|
|
102
|
-
`http://localhost:${port}/test_sitemap_bad.xml.gz`
|
|
103
|
-
],
|
|
104
|
-
urls: 5
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: "sitemap-index",
|
|
108
|
-
input: factory.create("sitemap-index"),
|
|
109
|
-
source: path.join(__dirname, "test_sitemap_index.xml"),
|
|
110
|
-
remote: [`http://localhost:${port}/test_sitemap_index.xml`],
|
|
111
|
-
// this is the total number of pages referenced by sitemaps in test_sitemap_index.
|
|
112
|
-
urls: 17
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: "sitemap-index-gzip",
|
|
116
|
-
input: factory.create("sitemap-index"),
|
|
117
|
-
source: path.join(__dirname, "test_sitemap_index.xml.gz"),
|
|
118
|
-
remote: [`http://localhost:${port}/test_sitemap_index.xml.gz`],
|
|
119
|
-
// this is the total number of pages referenced by sitemaps in test_sitemap_index.
|
|
120
|
-
urls: 17
|
|
121
|
-
}
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Escape a string for usage in a regular expression.
|
|
126
|
-
*/
|
|
127
|
-
function regexEscape(s) {
|
|
128
|
-
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function pathToRe (component) {
|
|
132
|
-
return regexEscape(component);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function urlToPath (url) {
|
|
136
|
-
let result = url;
|
|
137
|
-
if (process.platform === "win32") {
|
|
138
|
-
result = url.replace(/\//g, "\\");
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function urlToPathRe (url) {
|
|
144
|
-
let result = url;
|
|
145
|
-
if (process.platform === "win32") {
|
|
146
|
-
result = url.replace(/\//g, "\\\\");
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
inputGenerators.forEach(function (inputGeneratorTest) {
|
|
152
|
-
|
|
153
|
-
describe(inputGeneratorTest.name, function () {
|
|
154
|
-
|
|
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;
|
|
161
|
-
|
|
162
|
-
describe("general behavior", function () {
|
|
163
|
-
|
|
164
|
-
it("should return false for null", function () {
|
|
165
|
-
assert.equal(false, factory.isNull(gen));
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should have a run method", function (){
|
|
169
|
-
assert.equal(true, typeof gen.run === 'function');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// requires inputFile not found
|
|
173
|
-
it("should produce no input for defaults and a bogus file", function (done) {
|
|
174
|
-
let doneCalled = false;
|
|
175
|
-
|
|
176
|
-
gen.run(options.decorate({
|
|
177
|
-
source: "./bogus/file.txt",
|
|
178
|
-
outputDir: thisOutputDir,
|
|
179
|
-
_abort: function(err) {
|
|
180
|
-
assert.equal(true, !!err);
|
|
181
|
-
doneCalled = true;
|
|
182
|
-
done();
|
|
183
|
-
}
|
|
184
|
-
}), function () {
|
|
185
|
-
assert.fail("input callback should not have been called, unexpected input processed");
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
setTimeout(function () {
|
|
189
|
-
if (!doneCalled) {
|
|
190
|
-
done("abort was not called as expected");
|
|
191
|
-
}
|
|
192
|
-
}, 200);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// requires source to have 'urls' valid entries
|
|
196
|
-
it("should produce input with all defaults and a valid source", function (done) {
|
|
197
|
-
let count = 0;
|
|
198
|
-
|
|
199
|
-
const result = gen.run(options.decorate({
|
|
200
|
-
source: source,
|
|
201
|
-
outputDir: thisOutputDir
|
|
202
|
-
}), function () {
|
|
203
|
-
count++;
|
|
204
|
-
if (count === urls) {
|
|
205
|
-
done();
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
result
|
|
210
|
-
.then(function () {
|
|
211
|
-
assert.ok(true);
|
|
212
|
-
})
|
|
213
|
-
.catch(function (err) {
|
|
214
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
// this test has to match the base generator defaults
|
|
219
|
-
it("base defaults should exist in input when requested", function (done) {
|
|
220
|
-
const defaults = base.defaults({});
|
|
221
|
-
defaults.outputDir = thisOutputDir;
|
|
222
|
-
|
|
223
|
-
let count = 0;
|
|
224
|
-
const result = gen.run(options.decorate({
|
|
225
|
-
source: source,
|
|
226
|
-
outputDir: thisOutputDir
|
|
227
|
-
}), function (input) {
|
|
228
|
-
const re1 = new RegExp("^("+defaults.protocol+")://("+defaults.hostname+")/");
|
|
229
|
-
const re2 = new RegExp("^("+pathToRe(defaults.outputDir)+")"+pathToRe(path.sep));
|
|
230
|
-
|
|
231
|
-
const m1 = re1.exec(input.url);
|
|
232
|
-
const m2 = re2.exec(input.outputFile);
|
|
233
|
-
|
|
234
|
-
if (globalUrl) {
|
|
235
|
-
assert.equal(m1[1], defaults.protocol);
|
|
236
|
-
assert.equal(m1[2], defaults.hostname);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
assert.equal(m2[1], defaults.outputDir);
|
|
240
|
-
assert.equal(defaults.selector, input.selector);
|
|
241
|
-
assert.equal(defaults.timeout, input.timeout);
|
|
242
|
-
assert.equal(defaults.checkInterval, input.checkInterval);
|
|
243
|
-
assert.equal(defaults.useJQuery, input.useJQuery);
|
|
244
|
-
assert.equal(defaults.verbose, input.verbose);
|
|
245
|
-
|
|
246
|
-
count++;
|
|
247
|
-
if (count === urls) {
|
|
248
|
-
done();
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
result
|
|
253
|
-
.then(function () {
|
|
254
|
-
assert.ok(true);
|
|
255
|
-
})
|
|
256
|
-
.catch(function (err) {
|
|
257
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
describe("timeout option", function () {
|
|
264
|
-
|
|
265
|
-
it("should accept scalar and apply globally", function (done) {
|
|
266
|
-
let count = 0;
|
|
267
|
-
const theTimeout = 500;
|
|
268
|
-
|
|
269
|
-
const result = gen.run(options.decorate({
|
|
270
|
-
source: source,
|
|
271
|
-
outputDir: thisOutputDir,
|
|
272
|
-
timeout: theTimeout
|
|
273
|
-
}),
|
|
274
|
-
function (input) {
|
|
275
|
-
assert.equal(theTimeout, input.timeout);
|
|
276
|
-
count++;
|
|
277
|
-
if (count === urls) {
|
|
278
|
-
done();
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
result
|
|
283
|
-
.then(function () {
|
|
284
|
-
assert.ok(true);
|
|
285
|
-
})
|
|
286
|
-
.catch(function (err) {
|
|
287
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
// requires source to contain specific urls
|
|
292
|
-
it("should accept function and apply per url", function (done) {
|
|
293
|
-
const globalTimeouts = {
|
|
294
|
-
"/": 1,
|
|
295
|
-
"/contact": 2,
|
|
296
|
-
"/services/carpets": 3
|
|
297
|
-
};
|
|
298
|
-
const localTimeouts = {
|
|
299
|
-
"http://northstar.local": 1,
|
|
300
|
-
"http://northstar.local/contact": 2,
|
|
301
|
-
"http://northstar.local/services/carpets": 3
|
|
302
|
-
};
|
|
303
|
-
const timeouts = globalUrl ? globalTimeouts : localTimeouts;
|
|
304
|
-
|
|
305
|
-
const timeoutFn = function (url) {
|
|
306
|
-
return timeouts[url];
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
let count = 0;
|
|
310
|
-
|
|
311
|
-
const result = gen.run(options.decorate({
|
|
312
|
-
source: source,
|
|
313
|
-
outputDir: thisOutputDir,
|
|
314
|
-
timeout: timeoutFn
|
|
315
|
-
}),
|
|
316
|
-
function (input) {
|
|
317
|
-
const testTimeout =
|
|
318
|
-
timeouts[input.__page] ? timeouts[input.__page] : base.defaults({}).timeout;
|
|
319
|
-
|
|
320
|
-
assert.equal(input.timeout, testTimeout,
|
|
321
|
-
input.__page+":\ninput.timeout: "+input.timeout+" != testTimeout: "+testTimeout);
|
|
322
|
-
|
|
323
|
-
count++;
|
|
324
|
-
if (count === urls) {
|
|
325
|
-
done();
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
result
|
|
330
|
-
.then(function () {
|
|
331
|
-
assert.ok(true);
|
|
332
|
-
})
|
|
333
|
-
.catch(function (err) {
|
|
334
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it("should accept object and apply per url", function (done) {
|
|
339
|
-
const globalTimeouts = {
|
|
340
|
-
"/": 1,
|
|
341
|
-
"/contact": 2,
|
|
342
|
-
"/services/carpets": 3,
|
|
343
|
-
"__default": 4
|
|
344
|
-
};
|
|
345
|
-
const localTimeouts = {
|
|
346
|
-
"http://northstar.local": 470,
|
|
347
|
-
"http://northstar.local/contact": 480,
|
|
348
|
-
"http://northstar.local/services/carpets": 490,
|
|
349
|
-
"__default": 500
|
|
350
|
-
};
|
|
351
|
-
const timeouts = globalUrl ? globalTimeouts : localTimeouts;
|
|
352
|
-
let count = 0;
|
|
353
|
-
|
|
354
|
-
const result = gen.run(options.decorate({
|
|
355
|
-
source: source,
|
|
356
|
-
outputDir: thisOutputDir,
|
|
357
|
-
timeout: timeouts
|
|
358
|
-
}),
|
|
359
|
-
function (input) {
|
|
360
|
-
const testTimeout =
|
|
361
|
-
timeouts[input.__page] ? timeouts[input.__page] : timeouts.__default;
|
|
362
|
-
|
|
363
|
-
assert.equal(input.timeout, testTimeout,
|
|
364
|
-
input.__page+":\ninput.timeout: "+input.timeout+" != testTimeout: "+testTimeout);
|
|
365
|
-
|
|
366
|
-
count++;
|
|
367
|
-
if (count === urls) {
|
|
368
|
-
done();
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
result
|
|
373
|
-
.then(function () {
|
|
374
|
-
assert.ok(true);
|
|
375
|
-
})
|
|
376
|
-
.catch(function (err) {
|
|
377
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it("should accept object and apply per url, with missing __default",
|
|
382
|
-
function (done) {
|
|
383
|
-
const globalTimeouts = {
|
|
384
|
-
"/": 1,
|
|
385
|
-
"/contact": 2,
|
|
386
|
-
"/services/carpets": 3
|
|
387
|
-
};
|
|
388
|
-
const localTimeouts = {
|
|
389
|
-
"http://northstar.local": 1,
|
|
390
|
-
"http://northstar.local/contact": 2,
|
|
391
|
-
"http://northstar.local/services/carpets": 3
|
|
392
|
-
};
|
|
393
|
-
const timeouts = globalUrl ? globalTimeouts : localTimeouts;
|
|
394
|
-
let count = 0;
|
|
395
|
-
|
|
396
|
-
const result = gen.run(options.decorate({
|
|
397
|
-
source: source,
|
|
398
|
-
outputDir: thisOutputDir,
|
|
399
|
-
timeout: timeouts
|
|
400
|
-
}),
|
|
401
|
-
function (input) {
|
|
402
|
-
const testTimeout =
|
|
403
|
-
timeouts[input.__page] ? timeouts[input.__page] : base.defaults({}).timeout;
|
|
404
|
-
|
|
405
|
-
assert.equal(input.timeout, testTimeout,
|
|
406
|
-
input.__page+":\ninput.timeout: "+input.timeout+" != testTimeout: "+testTimeout);
|
|
407
|
-
|
|
408
|
-
count++;
|
|
409
|
-
if (count === urls) {
|
|
410
|
-
done();
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
result
|
|
415
|
-
.then(function () {
|
|
416
|
-
assert.ok(true);
|
|
417
|
-
})
|
|
418
|
-
.catch(function (err) {
|
|
419
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
420
|
-
})
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
describe("selector option", function () {
|
|
426
|
-
|
|
427
|
-
it("should accept scalar and apply globally", function (done) {
|
|
428
|
-
const selector = "foo";
|
|
429
|
-
let count = 0;
|
|
430
|
-
|
|
431
|
-
const result = gen.run(options.decorate({
|
|
432
|
-
source: source,
|
|
433
|
-
outputDir: thisOutputDir,
|
|
434
|
-
selector: selector
|
|
435
|
-
}),
|
|
436
|
-
function (input) {
|
|
437
|
-
assert.equal(input.selector, selector);
|
|
438
|
-
count++;
|
|
439
|
-
if (count === urls) {
|
|
440
|
-
done();
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
result
|
|
445
|
-
.then(function () {
|
|
446
|
-
assert.ok(true);
|
|
447
|
-
})
|
|
448
|
-
.catch(function (err) {
|
|
449
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
// requires source to contain specific urls
|
|
454
|
-
it("should accept function and apply per url", function (done) {
|
|
455
|
-
const globalSelectors = {
|
|
456
|
-
"/": "1",
|
|
457
|
-
"/contact": "2",
|
|
458
|
-
"/services/carpets": "3"
|
|
459
|
-
};
|
|
460
|
-
const localSelectors = {
|
|
461
|
-
"http://northstar.local/": "1",
|
|
462
|
-
"http://northstar.local/contact": "2",
|
|
463
|
-
"http://northstar.local/services/carpets": "3"
|
|
464
|
-
};
|
|
465
|
-
const selectors = globalUrl ? globalSelectors : localSelectors;
|
|
466
|
-
const selectorFn = function (url) {
|
|
467
|
-
return selectors[url];
|
|
468
|
-
};
|
|
469
|
-
let count = 0;
|
|
470
|
-
|
|
471
|
-
const result = gen.run(options.decorate({
|
|
472
|
-
source: source,
|
|
473
|
-
outputDir: thisOutputDir,
|
|
474
|
-
selector: selectorFn
|
|
475
|
-
}),
|
|
476
|
-
function (input) {
|
|
477
|
-
const testSelector =
|
|
478
|
-
selectors[input.__page] ? selectors[input.__page] : base.defaults({}).selector;
|
|
479
|
-
|
|
480
|
-
assert.equal(input.selector, testSelector,
|
|
481
|
-
input.__page+":\ninput.selector: "+input.selector+" != testSelector: "+testSelector);
|
|
482
|
-
|
|
483
|
-
count++;
|
|
484
|
-
if (count === urls) {
|
|
485
|
-
done();
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
result
|
|
490
|
-
.then(function () {
|
|
491
|
-
assert.ok(true);
|
|
492
|
-
})
|
|
493
|
-
.catch(function (err) {
|
|
494
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it("should accept object and apply per url", function (done) {
|
|
499
|
-
const globalSelectors = {
|
|
500
|
-
"/": "1",
|
|
501
|
-
"/contact": "2",
|
|
502
|
-
"/services/carpets": "3",
|
|
503
|
-
"__default": "50"
|
|
504
|
-
};
|
|
505
|
-
const localSelectors = {
|
|
506
|
-
"http://northstar.local/": "1",
|
|
507
|
-
"http://northstar.local/contact": "2",
|
|
508
|
-
"http://northstar.local/services/carpets": "3",
|
|
509
|
-
"__default": "50"
|
|
510
|
-
};
|
|
511
|
-
const selectors = globalUrl ? globalSelectors : localSelectors;
|
|
512
|
-
let count = 0;
|
|
513
|
-
|
|
514
|
-
const result = gen.run(options.decorate({
|
|
515
|
-
source: source,
|
|
516
|
-
outputDir: thisOutputDir,
|
|
517
|
-
selector: selectors
|
|
518
|
-
}),
|
|
519
|
-
function (input) {
|
|
520
|
-
const testSelector =
|
|
521
|
-
selectors[input.__page] ? selectors[input.__page] : selectors.__default;
|
|
522
|
-
|
|
523
|
-
assert.equal(input.selector, testSelector,
|
|
524
|
-
input.__page+":\ninput.selector: "+input.selector+" != testSelector: "+testSelector);
|
|
525
|
-
|
|
526
|
-
count++;
|
|
527
|
-
if (count === urls) {
|
|
528
|
-
done();
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
result
|
|
533
|
-
.then(function () {
|
|
534
|
-
assert.ok(true);
|
|
535
|
-
})
|
|
536
|
-
.catch(function (err) {
|
|
537
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
describe("useJQuery option", function () {
|
|
544
|
-
|
|
545
|
-
it("should accept a scalar and apply globally",
|
|
546
|
-
function (done) {
|
|
547
|
-
const useJQuery = true;
|
|
548
|
-
let count = 0;
|
|
549
|
-
|
|
550
|
-
const result = gen.run(options.decorate({
|
|
551
|
-
source: source,
|
|
552
|
-
outputDir: thisOutputDir,
|
|
553
|
-
useJQuery: useJQuery
|
|
554
|
-
}), function (input) {
|
|
555
|
-
assert.equal(input.useJQuery, useJQuery);
|
|
556
|
-
count++;
|
|
557
|
-
if (count === urls) {
|
|
558
|
-
done();
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
result
|
|
563
|
-
.then(function () {
|
|
564
|
-
assert.ok(true);
|
|
565
|
-
})
|
|
566
|
-
.catch(function (err) {
|
|
567
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
it("should accept an object and apply per url", function (done) {
|
|
572
|
-
const globalOptions = {
|
|
573
|
-
"/": false,
|
|
574
|
-
"/contact": true,
|
|
575
|
-
"/services/carpets": false,
|
|
576
|
-
"__default": true
|
|
577
|
-
};
|
|
578
|
-
const localOptions = {
|
|
579
|
-
"http://northstar.local/": false,
|
|
580
|
-
"http://northstar.local/contact": true,
|
|
581
|
-
"http://northstar.local/services/carpets": false,
|
|
582
|
-
"__default": true
|
|
583
|
-
};
|
|
584
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
585
|
-
let count = 0;
|
|
586
|
-
|
|
587
|
-
const result = gen.run(options.decorate({
|
|
588
|
-
source: source,
|
|
589
|
-
outputDir: thisOutputDir,
|
|
590
|
-
useJQuery: opts
|
|
591
|
-
}), function (input) {
|
|
592
|
-
const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
|
|
593
|
-
|
|
594
|
-
assert.equal(input.useJQuery, testOption,
|
|
595
|
-
input.__page+":\ninput.useJQuery: "+input.useJQuery+" != testUseJQuery: "+testOption);
|
|
596
|
-
|
|
597
|
-
count++;
|
|
598
|
-
if (count === urls) {
|
|
599
|
-
done();
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
result
|
|
604
|
-
.then(function () {
|
|
605
|
-
assert.ok(true);
|
|
606
|
-
})
|
|
607
|
-
.catch(function (err) {
|
|
608
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
609
|
-
});
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
it("should accept a function and apply per url", function (done) {
|
|
613
|
-
const globalOptions = {
|
|
614
|
-
"/": false,
|
|
615
|
-
"/contact": true,
|
|
616
|
-
"/services/carpets": false
|
|
617
|
-
};
|
|
618
|
-
const localOptions = {
|
|
619
|
-
"http://northstar.local/": false,
|
|
620
|
-
"http://northstar.local/contact": true,
|
|
621
|
-
"http://northstar.local/services/carpets": false
|
|
622
|
-
};
|
|
623
|
-
let count = 0;
|
|
624
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
625
|
-
const useJQFn = function (url) {
|
|
626
|
-
return opts[url];
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
const result = gen.run(options.decorate({
|
|
630
|
-
source: source,
|
|
631
|
-
outputDir: thisOutputDir,
|
|
632
|
-
useJQuery: useJQFn
|
|
633
|
-
}), function (input) {
|
|
634
|
-
const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).useJQuery;
|
|
635
|
-
|
|
636
|
-
assert.equal(input.useJQuery, testOption,
|
|
637
|
-
input.__page+":\ninput.useJQuery: "+input.useJQuery+" != testUseJQuery: "+testOption);
|
|
638
|
-
|
|
639
|
-
count++;
|
|
640
|
-
if (count === urls) {
|
|
641
|
-
done();
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
result
|
|
646
|
-
.then(function () {
|
|
647
|
-
assert.ok(true);
|
|
648
|
-
})
|
|
649
|
-
.catch(function (err) {
|
|
650
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
describe("verbose option", function () {
|
|
657
|
-
|
|
658
|
-
it("should accept a scalar and apply globally",
|
|
659
|
-
function (done) {
|
|
660
|
-
const verbose = true;
|
|
661
|
-
let count = 0;
|
|
662
|
-
|
|
663
|
-
const result = gen.run(options.decorate({
|
|
664
|
-
source: source,
|
|
665
|
-
outputDir: thisOutputDir,
|
|
666
|
-
verbose: verbose
|
|
667
|
-
}), function (input) {
|
|
668
|
-
assert.equal(input.verbose, verbose);
|
|
669
|
-
count++;
|
|
670
|
-
if (count === urls) {
|
|
671
|
-
done();
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
result
|
|
676
|
-
.then(function () {
|
|
677
|
-
assert.ok(true);
|
|
678
|
-
})
|
|
679
|
-
.catch(function (err) {
|
|
680
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
681
|
-
});
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
it("should accept an object and apply per url", function (done) {
|
|
685
|
-
const globalOptions = {
|
|
686
|
-
"/": false,
|
|
687
|
-
"/contact": true,
|
|
688
|
-
"/services/carpets": false,
|
|
689
|
-
"__default": true
|
|
690
|
-
};
|
|
691
|
-
const localOptions = {
|
|
692
|
-
"http://northstar.local/": false,
|
|
693
|
-
"http://northstar.local/contact": true,
|
|
694
|
-
"http://northstar.local/services/carpets": false,
|
|
695
|
-
"__default": true
|
|
696
|
-
};
|
|
697
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
698
|
-
let count = 0;
|
|
699
|
-
|
|
700
|
-
const result = gen.run(options.decorate({
|
|
701
|
-
source: source,
|
|
702
|
-
outputDir: thisOutputDir,
|
|
703
|
-
verbose: opts
|
|
704
|
-
}), function (input) {
|
|
705
|
-
const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
|
|
706
|
-
|
|
707
|
-
assert.equal(input.verbose, testOption,
|
|
708
|
-
input.__page+":\ninput.verbose: "+input.verbose+" != testVerbose: "+testOption);
|
|
709
|
-
|
|
710
|
-
count++;
|
|
711
|
-
if (count === urls) {
|
|
712
|
-
done();
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
result
|
|
717
|
-
.then(function () {
|
|
718
|
-
assert.ok(true);
|
|
719
|
-
})
|
|
720
|
-
.catch(function (err) {
|
|
721
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
|
|
725
|
-
it("should accept a function and apply per url", function (done) {
|
|
726
|
-
const globalOptions = {
|
|
727
|
-
"/": false,
|
|
728
|
-
"/contact": true,
|
|
729
|
-
"/services/carpets": false
|
|
730
|
-
};
|
|
731
|
-
const localOptions = {
|
|
732
|
-
"http://northstar.local/": false,
|
|
733
|
-
"http://northstar.local/contact": true,
|
|
734
|
-
"http://northstar.local/services/carpets": false
|
|
735
|
-
};
|
|
736
|
-
let count = 0;
|
|
737
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
738
|
-
const useVerboseFn = function (url) {
|
|
739
|
-
return opts[url];
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
const result = gen.run(options.decorate({
|
|
743
|
-
source: source,
|
|
744
|
-
outputDir: thisOutputDir,
|
|
745
|
-
verbose: useVerboseFn
|
|
746
|
-
}), function (input) {
|
|
747
|
-
const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).verbose;
|
|
748
|
-
|
|
749
|
-
assert.equal(input.verbose, testOption,
|
|
750
|
-
input.__page+":\ninput.verbose: "+input.verbose+" != testUseVerbose: "+testOption);
|
|
751
|
-
|
|
752
|
-
count++;
|
|
753
|
-
if (count === urls) {
|
|
754
|
-
done();
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
result
|
|
759
|
-
.then(function () {
|
|
760
|
-
assert.ok(true);
|
|
761
|
-
})
|
|
762
|
-
.catch(function (err) {
|
|
763
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
describe("phantomjsOptions option", function () {
|
|
770
|
-
|
|
771
|
-
it("should accept a single string and apply globally", function (done) {
|
|
772
|
-
const phantomjsOption = "--version";
|
|
773
|
-
let count = 0;
|
|
774
|
-
|
|
775
|
-
const result = gen.run(options.decorate({
|
|
776
|
-
source: source,
|
|
777
|
-
outputDir: thisOutputDir,
|
|
778
|
-
phantomjsOptions: phantomjsOption
|
|
779
|
-
}), function (input) {
|
|
780
|
-
|
|
781
|
-
assert.equal(input.phantomjsOptions, phantomjsOption,
|
|
782
|
-
input.__page+":\ninput.phantomjsOptions should be equal to the original input");
|
|
783
|
-
|
|
784
|
-
count++;
|
|
785
|
-
if (count === urls) {
|
|
786
|
-
done();
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
result
|
|
791
|
-
.then(function () {
|
|
792
|
-
assert.ok(true);
|
|
793
|
-
})
|
|
794
|
-
.catch(function (err) {
|
|
795
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
796
|
-
});
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
it("should accept a single array and apply globally", function (done) {
|
|
800
|
-
const phantomjsOption = ["--version", "--help"];
|
|
801
|
-
let count = 0;
|
|
802
|
-
|
|
803
|
-
const result = gen.run(options.decorate({
|
|
804
|
-
source: source,
|
|
805
|
-
outputDir: thisOutputDir,
|
|
806
|
-
phantomjsOptions: phantomjsOption
|
|
807
|
-
}), function (input) {
|
|
808
|
-
|
|
809
|
-
assert.equal(typeof input.phantomjsOptions, typeof phantomjsOption,
|
|
810
|
-
input.__page+":\ninput.phantomjsOptions should be an array:\n"+
|
|
811
|
-
require("util").inspect(input.phantomjsOptions));
|
|
812
|
-
|
|
813
|
-
assert.deepEqual(input.phantomjsOptions, phantomjsOption,
|
|
814
|
-
input.__page+":\ninput.phantomjsOptions should be equal to the original input");
|
|
815
|
-
|
|
816
|
-
count++;
|
|
817
|
-
if (count === urls) {
|
|
818
|
-
done();
|
|
819
|
-
}
|
|
820
|
-
});
|
|
821
|
-
|
|
822
|
-
result
|
|
823
|
-
.then(function () {
|
|
824
|
-
assert.ok(true);
|
|
825
|
-
})
|
|
826
|
-
.catch(function (err) {
|
|
827
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
|
|
831
|
-
it("should accept an object and apply per url", function (done) {
|
|
832
|
-
const phantomjsOption1 = "--version",
|
|
833
|
-
phantomjsOption2 = ["--help"],
|
|
834
|
-
phantomjsOption3 = ["--another-option=somevalue", "--some-other-option=someother"];
|
|
835
|
-
|
|
836
|
-
const globalOptions = {
|
|
837
|
-
"/": phantomjsOption1,
|
|
838
|
-
"/contact": phantomjsOption2,
|
|
839
|
-
"/services/carpets": phantomjsOption3,
|
|
840
|
-
"__default": ""
|
|
841
|
-
};
|
|
842
|
-
const localOptions = {
|
|
843
|
-
"http://northstar.local/": phantomjsOption1,
|
|
844
|
-
"http://northstar.local/contact": phantomjsOption2,
|
|
845
|
-
"http://northstar.local/services/carpets": phantomjsOption3,
|
|
846
|
-
"__default": ""
|
|
847
|
-
};
|
|
848
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
849
|
-
let count = 0;
|
|
850
|
-
|
|
851
|
-
const result = gen.run(options.decorate({
|
|
852
|
-
source: source,
|
|
853
|
-
outputDir: thisOutputDir,
|
|
854
|
-
phantomjsOptions: opts
|
|
855
|
-
}), function (input) {
|
|
856
|
-
const testOption = opts[input.__page] !== void 0 ? opts[input.__page] : opts.__default;
|
|
857
|
-
|
|
858
|
-
assert.deepEqual(input.phantomjsOptions, testOption,
|
|
859
|
-
input.__page+":\ninput.phantomjsOptions: "+input.phantomjsOptions+" != testPhantomJSOption: "+testOption);
|
|
860
|
-
|
|
861
|
-
count++;
|
|
862
|
-
if (count === urls) {
|
|
863
|
-
done();
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
result
|
|
868
|
-
.then(function () {
|
|
869
|
-
assert.ok(true);
|
|
870
|
-
})
|
|
871
|
-
.catch(function (err) {
|
|
872
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
873
|
-
});
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
it("should accept a function and apply per url", function (done) {
|
|
877
|
-
const phantomjsOption1 = "--version",
|
|
878
|
-
phantomjsOption2 = ["--help"],
|
|
879
|
-
phantomjsOption3 = ["--another-option=somevalue", "--some-other-option=someother"];
|
|
880
|
-
|
|
881
|
-
const globalOptions = {
|
|
882
|
-
"/": phantomjsOption1,
|
|
883
|
-
"/contact": phantomjsOption2,
|
|
884
|
-
"/services/carpets": phantomjsOption3
|
|
885
|
-
};
|
|
886
|
-
const localOptions = {
|
|
887
|
-
"http://northstar.local/": phantomjsOption1,
|
|
888
|
-
"http://northstar.local/contact": phantomjsOption2,
|
|
889
|
-
"http://northstar.local/services/carpets": phantomjsOption3
|
|
890
|
-
};
|
|
891
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
892
|
-
let count = 0;
|
|
893
|
-
const phantomjsFn = function (url) {
|
|
894
|
-
return opts[url];
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
const result = gen.run(options.decorate({
|
|
898
|
-
source: source,
|
|
899
|
-
outputDir: thisOutputDir,
|
|
900
|
-
phantomjsOptions: phantomjsFn
|
|
901
|
-
}), function (input) {
|
|
902
|
-
const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).phantomjsOptions;
|
|
903
|
-
|
|
904
|
-
assert.deepEqual(input.phantomjsOptions, testOption,
|
|
905
|
-
input.__page+":\ninput.phantomjsOptions: "+input.phantomjsOptions+" != testPhantomJSOption: "+testOption);
|
|
906
|
-
|
|
907
|
-
count++;
|
|
908
|
-
if (count === urls) {
|
|
909
|
-
done();
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
result
|
|
914
|
-
.then(function () {
|
|
915
|
-
assert.ok(true);
|
|
916
|
-
})
|
|
917
|
-
.catch(function (err) {
|
|
918
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
919
|
-
});
|
|
920
|
-
});
|
|
921
|
-
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
describe("puppeteerLaunchOptions option", function () {
|
|
925
|
-
it("should accept a single object and apply globally", function (done) {
|
|
926
|
-
let count = 0;
|
|
927
|
-
const puppeteerLaunchOptions = {
|
|
928
|
-
one: 'one',
|
|
929
|
-
two: 2,
|
|
930
|
-
three: ['three', 'four', 'five'],
|
|
931
|
-
six: {
|
|
932
|
-
seven: 'seven'
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
const result = gen.run(options.decorate({
|
|
937
|
-
source,
|
|
938
|
-
puppeteerLaunchOptions,
|
|
939
|
-
outputDir: thisOutputDir
|
|
940
|
-
}), function (input) {
|
|
941
|
-
const classString = Object.prototype.toString;
|
|
942
|
-
|
|
943
|
-
assert.equal(classString.call(input.puppeteerLaunchOptions), classString.call(puppeteerLaunchOptions),
|
|
944
|
-
`${input.__page}:\ninput.puppeteerLaunchOptions should be an object:\n${
|
|
945
|
-
require("util").inspect(input.puppeteerLaunchOptions)
|
|
946
|
-
}`
|
|
947
|
-
);
|
|
948
|
-
|
|
949
|
-
assert.deepEqual(input.puppeteerLaunchOptions, puppeteerLaunchOptions,
|
|
950
|
-
`${input.__page}:\ninput.puppeteerLaunchOptions should be equal to the original input`);
|
|
951
|
-
|
|
952
|
-
count++;
|
|
953
|
-
if (count === urls) {
|
|
954
|
-
done();
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
|
|
958
|
-
result
|
|
959
|
-
.then(function () {
|
|
960
|
-
assert.ok(true);
|
|
961
|
-
})
|
|
962
|
-
.catch(function (err) {
|
|
963
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
it("should accept a function and apply per url", function (done) {
|
|
968
|
-
const plo1 = { one: "one" },
|
|
969
|
-
plo2 = { two: "two" },
|
|
970
|
-
plo3 = { three: "three" };
|
|
971
|
-
|
|
972
|
-
const globalOptions = {
|
|
973
|
-
"/": plo1,
|
|
974
|
-
"/contact": plo2,
|
|
975
|
-
"/services/carpets": plo3
|
|
976
|
-
};
|
|
977
|
-
const localOptions = {
|
|
978
|
-
"http://northstar.local/": plo1,
|
|
979
|
-
"http://northstar.local/contact": plo2,
|
|
980
|
-
"http://northstar.local/services/carpets": plo3
|
|
981
|
-
};
|
|
982
|
-
const opts = globalUrl ? globalOptions : localOptions;
|
|
983
|
-
let count = 0;
|
|
984
|
-
const ploFn = function (url) {
|
|
985
|
-
return opts[url];
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
const result = gen.run(options.decorate({
|
|
989
|
-
source: source,
|
|
990
|
-
outputDir: thisOutputDir,
|
|
991
|
-
puppeteerLaunchOptions: ploFn
|
|
992
|
-
}), function (input) {
|
|
993
|
-
const testOption = opts[input.__page] ? opts[input.__page] : base.defaults({}).puppeteerLaunchOptions;
|
|
994
|
-
|
|
995
|
-
assert.deepEqual(input.puppeteerLaunchOptions, testOption,
|
|
996
|
-
`${input.__page}:\ninput.puppeteerLaunchOptions: ${input.puppeteerLaunchOptions} != testPuppeteerLaunchOption: ${testOption}`);
|
|
997
|
-
|
|
998
|
-
count++;
|
|
999
|
-
if (count === urls) {
|
|
1000
|
-
done();
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
result
|
|
1005
|
-
.then(function () {
|
|
1006
|
-
assert.ok(true);
|
|
1007
|
-
})
|
|
1008
|
-
.catch(function (err) {
|
|
1009
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1010
|
-
});
|
|
1011
|
-
});
|
|
1012
|
-
});
|
|
1013
|
-
|
|
1014
|
-
describe("url behavior", function () {
|
|
1015
|
-
|
|
1016
|
-
it("should replace the default hostname in results", function (done) {
|
|
1017
|
-
const hostname = "foo";
|
|
1018
|
-
let count = 0;
|
|
1019
|
-
|
|
1020
|
-
const result = gen.run(options.decorate({
|
|
1021
|
-
source: source,
|
|
1022
|
-
outputDir: thisOutputDir,
|
|
1023
|
-
hostname: hostname
|
|
1024
|
-
}),
|
|
1025
|
-
function (input) {
|
|
1026
|
-
const re = new RegExp(`http://(${hostname})/`);
|
|
1027
|
-
const match = re.exec(input.url);
|
|
1028
|
-
if (globalUrl) {
|
|
1029
|
-
assert.equal(match[1], hostname);
|
|
1030
|
-
} else {
|
|
1031
|
-
assert.equal(match === null, true);
|
|
1032
|
-
}
|
|
1033
|
-
count++;
|
|
1034
|
-
if (count === urls) {
|
|
1035
|
-
done();
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
|
|
1039
|
-
result
|
|
1040
|
-
.then(function () {
|
|
1041
|
-
assert.ok(true);
|
|
1042
|
-
})
|
|
1043
|
-
.catch(function (err) {
|
|
1044
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1045
|
-
});
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
it("should replace the default protocol in results", function (done) {
|
|
1049
|
-
const proto = "file";
|
|
1050
|
-
let count = 0;
|
|
1051
|
-
|
|
1052
|
-
const result = gen.run(options.decorate({
|
|
1053
|
-
source: source,
|
|
1054
|
-
outputDir: thisOutputDir,
|
|
1055
|
-
protocol: proto
|
|
1056
|
-
}),
|
|
1057
|
-
function (input) {
|
|
1058
|
-
const re = new RegExp(`^(${proto})://`);
|
|
1059
|
-
const match = re.exec(input.url);
|
|
1060
|
-
if (globalUrl) {
|
|
1061
|
-
assert.equal(match[1], proto);
|
|
1062
|
-
} else {
|
|
1063
|
-
assert.equal(match === null, true);
|
|
1064
|
-
}
|
|
1065
|
-
count++;
|
|
1066
|
-
if (count === urls) {
|
|
1067
|
-
done();
|
|
1068
|
-
}
|
|
1069
|
-
});
|
|
1070
|
-
|
|
1071
|
-
result
|
|
1072
|
-
.then(function () {
|
|
1073
|
-
assert.ok(true);
|
|
1074
|
-
})
|
|
1075
|
-
.catch(function (err) {
|
|
1076
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
it("should contain a port in the url if one is specified",
|
|
1081
|
-
function (done) {
|
|
1082
|
-
const port = 8080;
|
|
1083
|
-
let count = 0;
|
|
1084
|
-
|
|
1085
|
-
const result = gen.run(options.decorate({
|
|
1086
|
-
source: source,
|
|
1087
|
-
outputDir: thisOutputDir,
|
|
1088
|
-
port: port
|
|
1089
|
-
}),
|
|
1090
|
-
function (input) {
|
|
1091
|
-
const re = new RegExp(`^http://localhost\\:(${port})/`);
|
|
1092
|
-
const match = re.exec(input.url);
|
|
1093
|
-
if (globalUrl) {
|
|
1094
|
-
assert.equal(match[1], port);
|
|
1095
|
-
} else {
|
|
1096
|
-
assert.equal(match === null, true);
|
|
1097
|
-
}
|
|
1098
|
-
count++;
|
|
1099
|
-
if (count === urls) {
|
|
1100
|
-
done();
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
|
-
|
|
1104
|
-
result
|
|
1105
|
-
.then(function () {
|
|
1106
|
-
assert.ok(true);
|
|
1107
|
-
})
|
|
1108
|
-
.catch(function (err) {
|
|
1109
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1110
|
-
});
|
|
1111
|
-
});
|
|
1112
|
-
|
|
1113
|
-
it("should contain an auth in the url if one is specified",
|
|
1114
|
-
function (done) {
|
|
1115
|
-
const auth = "user:pass";
|
|
1116
|
-
let count = 0;
|
|
1117
|
-
|
|
1118
|
-
const result = gen.run(options.decorate({
|
|
1119
|
-
source: source,
|
|
1120
|
-
outputDir: thisOutputDir,
|
|
1121
|
-
auth: auth
|
|
1122
|
-
}),
|
|
1123
|
-
function (input) {
|
|
1124
|
-
const re = new RegExp(`^http://(${auth})@localhost/`);
|
|
1125
|
-
const match = re.exec(input.url);
|
|
1126
|
-
if (globalUrl) {
|
|
1127
|
-
assert.equal(match[1], auth);
|
|
1128
|
-
} else {
|
|
1129
|
-
assert.equal(match === null, true);
|
|
1130
|
-
}
|
|
1131
|
-
count++;
|
|
1132
|
-
if (count === urls) {
|
|
1133
|
-
done();
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
|
-
result
|
|
1138
|
-
.then(function () {
|
|
1139
|
-
assert.ok(true);
|
|
1140
|
-
})
|
|
1141
|
-
.catch(function (err) {
|
|
1142
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1143
|
-
});
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
if (remote) {
|
|
1147
|
-
remote.forEach(remoteUrl => {
|
|
1148
|
-
it(`should process remote source url ${remoteUrl}`, function (done) {
|
|
1149
|
-
this.timeout(5000);
|
|
1150
|
-
let count = 0;
|
|
1151
|
-
|
|
1152
|
-
const result = gen.run(options.decorate({
|
|
1153
|
-
source: remoteUrl,
|
|
1154
|
-
outputDir: thisOutputDir,
|
|
1155
|
-
_abort: function (err) {
|
|
1156
|
-
assert.fail(`${remoteUrl} should not have aborted: ${err.toString()}`);
|
|
1157
|
-
}
|
|
1158
|
-
}), function (input) {
|
|
1159
|
-
assert(true, common.isUrl(input.url));
|
|
1160
|
-
count++;
|
|
1161
|
-
if (count === urls) {
|
|
1162
|
-
done();
|
|
1163
|
-
}
|
|
1164
|
-
});
|
|
1165
|
-
|
|
1166
|
-
result
|
|
1167
|
-
.then(function () {
|
|
1168
|
-
assert.ok(true);
|
|
1169
|
-
})
|
|
1170
|
-
.catch(function (err) {
|
|
1171
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1172
|
-
});
|
|
1173
|
-
});
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (bad) {
|
|
1178
|
-
bad.forEach(badSource => {
|
|
1179
|
-
it(`should handle bad source ${badSource}`, function (done) {
|
|
1180
|
-
this.timeout(10000);
|
|
1181
|
-
gen.run(options.decorate({
|
|
1182
|
-
source: badSource,
|
|
1183
|
-
outputDir: thisOutputDir,
|
|
1184
|
-
_abort: function (err) {
|
|
1185
|
-
// console.log(`@@@ ${badSource} should have aborted with error`);
|
|
1186
|
-
assert.equal(true, !!err, `${badSource} should have aborted with error`);
|
|
1187
|
-
done();
|
|
1188
|
-
}
|
|
1189
|
-
}), function () {
|
|
1190
|
-
//console.log("@@@ bad input:\n"+require("util").inspect(input));
|
|
1191
|
-
assert.fail(`Input handler was called unexpectedly for badSource: ${badSource}`);
|
|
1192
|
-
done(true);
|
|
1193
|
-
});
|
|
1194
|
-
});
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
|
|
1199
|
-
describe("checkInterval option", function () {
|
|
1200
|
-
|
|
1201
|
-
it("should replace the default checkInterval globally", function (done) {
|
|
1202
|
-
const checkInterval = 1;
|
|
1203
|
-
let count = 0;
|
|
1204
|
-
|
|
1205
|
-
const result = gen.run(options.decorate({
|
|
1206
|
-
source: source,
|
|
1207
|
-
outputDir: thisOutputDir,
|
|
1208
|
-
checkInterval: checkInterval
|
|
1209
|
-
}), function (input) {
|
|
1210
|
-
assert.equal(input.checkInterval, checkInterval);
|
|
1211
|
-
count++;
|
|
1212
|
-
if (count === urls) {
|
|
1213
|
-
done();
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
|
|
1217
|
-
result
|
|
1218
|
-
.then(function () {
|
|
1219
|
-
assert.ok(true);
|
|
1220
|
-
})
|
|
1221
|
-
.catch(function (err) {
|
|
1222
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1223
|
-
});
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
});
|
|
1227
|
-
|
|
1228
|
-
describe("output file behavior", function () {
|
|
1229
|
-
|
|
1230
|
-
it("should contain the snapshot directory in output outfile spec",
|
|
1231
|
-
function (done) {
|
|
1232
|
-
const snapshotDir = "foo";
|
|
1233
|
-
let count = 0;
|
|
1234
|
-
|
|
1235
|
-
const result = gen.run(options.decorate({
|
|
1236
|
-
source: source,
|
|
1237
|
-
outputDir: path.join(thisOutputDir, snapshotDir)
|
|
1238
|
-
}), function (input) {
|
|
1239
|
-
const re = new RegExp("\\"+path.sep+"("+snapshotDir+")"+"\\"+path.sep);
|
|
1240
|
-
const match = re.exec(input.outputFile);
|
|
1241
|
-
assert.equal(match[1], snapshotDir);
|
|
1242
|
-
count++;
|
|
1243
|
-
if (count === urls) {
|
|
1244
|
-
done();
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
|
|
1248
|
-
result
|
|
1249
|
-
.then(function () {
|
|
1250
|
-
assert.ok(true);
|
|
1251
|
-
})
|
|
1252
|
-
.catch(function (err) {
|
|
1253
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1254
|
-
});
|
|
1255
|
-
});
|
|
1256
|
-
|
|
1257
|
-
// requires inputFile to contain specific urls
|
|
1258
|
-
it("should contain the page structure in the output file spec",
|
|
1259
|
-
function (done) {
|
|
1260
|
-
const snapshotDir = "foo";
|
|
1261
|
-
const pages = !globalUrl ? {
|
|
1262
|
-
"http://northstar.local/": "/",
|
|
1263
|
-
"http://northstar.local/contact": "/contact",
|
|
1264
|
-
"http://northstar.local/services/carpets": "/services/carpets",
|
|
1265
|
-
"http://northstar.local/services/test?arg=one": "/services/test",
|
|
1266
|
-
"https://northstar.local/services/#hash": "/services"
|
|
1267
|
-
} : {
|
|
1268
|
-
"/": "/",
|
|
1269
|
-
"/contact": "/contact",
|
|
1270
|
-
"/services/carpets": "/services/carpets",
|
|
1271
|
-
"/services/test?arg=one": "/services/test",
|
|
1272
|
-
"/services/#hash": "/services"
|
|
1273
|
-
};
|
|
1274
|
-
let count = 0;
|
|
1275
|
-
|
|
1276
|
-
const result = gen.run(options.decorate({
|
|
1277
|
-
source: source,
|
|
1278
|
-
outputDir: path.join(thisOutputDir, snapshotDir)
|
|
1279
|
-
}), function (input) {
|
|
1280
|
-
const re = new RegExp("("+snapshotDir+")("+urlToPathRe(pages[input.__page])+")");
|
|
1281
|
-
const match = re.exec(input.outputFile);
|
|
1282
|
-
|
|
1283
|
-
assert.equal(true, match[1] === snapshotDir && match[2] === urlToPath(pages[input.__page]));
|
|
1284
|
-
|
|
1285
|
-
count++;
|
|
1286
|
-
if (count === urls) {
|
|
1287
|
-
done();
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
result
|
|
1292
|
-
.then(function () {
|
|
1293
|
-
assert.ok(true);
|
|
1294
|
-
})
|
|
1295
|
-
.catch(function (err) {
|
|
1296
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1297
|
-
});
|
|
1298
|
-
});
|
|
1299
|
-
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
describe("outputPath option", function () {
|
|
1303
|
-
it("should lookup an outputPath (per page from a function) if one is specified",
|
|
1304
|
-
function (done) {
|
|
1305
|
-
const argOne = "/services/test/arg/one";
|
|
1306
|
-
const hash = "/services/hash";
|
|
1307
|
-
const pages = !globalUrl ? {
|
|
1308
|
-
"http://northstar.local/": "/",
|
|
1309
|
-
"http://northstar.local/contact": "/contact",
|
|
1310
|
-
"http://northstar.local/services/carpets": "/services/carpets",
|
|
1311
|
-
"http://northstar.local/services/test?arg=one": argOne,
|
|
1312
|
-
"https://northstar.local/services/#hash": hash
|
|
1313
|
-
} : {
|
|
1314
|
-
"/": "/",
|
|
1315
|
-
"/contact": "/contact",
|
|
1316
|
-
"/services/carpets": "/services/carpets",
|
|
1317
|
-
"/services/test?arg=one": argOne,
|
|
1318
|
-
"/services/#hash": hash
|
|
1319
|
-
};
|
|
1320
|
-
let count = 0;
|
|
1321
|
-
|
|
1322
|
-
const result = gen.run(options.decorate({
|
|
1323
|
-
source: source,
|
|
1324
|
-
outputPath: function (p) {
|
|
1325
|
-
return pages[p];
|
|
1326
|
-
},
|
|
1327
|
-
outputDir: thisOutputDir
|
|
1328
|
-
}), function (input) {
|
|
1329
|
-
const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
|
|
1330
|
-
const match = re.exec(input.outputFile);
|
|
1331
|
-
assert.equal(match[1], urlToPath(pages[input.__page]));
|
|
1332
|
-
count++;
|
|
1333
|
-
if (count === urls) {
|
|
1334
|
-
done();
|
|
1335
|
-
}
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
result
|
|
1339
|
-
.then(function () {
|
|
1340
|
-
assert.ok(true);
|
|
1341
|
-
})
|
|
1342
|
-
.catch(function (err) {
|
|
1343
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1344
|
-
});
|
|
1345
|
-
});
|
|
1346
|
-
|
|
1347
|
-
it("should lookup an outputPath (from a hash) and find it in the outputFile spec",
|
|
1348
|
-
function (done) {
|
|
1349
|
-
const argOne = "/services/test/arg/one";
|
|
1350
|
-
const hash = "/services/hash";
|
|
1351
|
-
const outputPath = !globalUrl ? {
|
|
1352
|
-
"http://northstar.local/services/test?arg=one": argOne,
|
|
1353
|
-
"https://northstar.local/services/#hash": hash
|
|
1354
|
-
} : { "/services/test?arg=one": argOne, "/services/#hash": hash };
|
|
1355
|
-
const pages = !globalUrl ? {
|
|
1356
|
-
"http://northstar.local/": "/",
|
|
1357
|
-
"http://northstar.local/contact": "/contact",
|
|
1358
|
-
"http://northstar.local/services/carpets": "/services/carpets",
|
|
1359
|
-
"http://northstar.local/services/test?arg=one": argOne,
|
|
1360
|
-
"https://northstar.local/services/#hash": hash
|
|
1361
|
-
} : {
|
|
1362
|
-
"/": "/",
|
|
1363
|
-
"/contact": "/contact",
|
|
1364
|
-
"/services/carpets": "/services/carpets",
|
|
1365
|
-
"/services/test?arg=one": argOne,
|
|
1366
|
-
"/services/#hash": hash
|
|
1367
|
-
};
|
|
1368
|
-
let count = 0;
|
|
1369
|
-
|
|
1370
|
-
const result = gen.run(options.decorate({
|
|
1371
|
-
source: source,
|
|
1372
|
-
outputDir: thisOutputDir,
|
|
1373
|
-
outputPath: outputPath
|
|
1374
|
-
}), function (input) {
|
|
1375
|
-
const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
|
|
1376
|
-
const match = re.exec(input.outputFile);
|
|
1377
|
-
assert.equal(match[1], urlToPath(pages[input.__page]));
|
|
1378
|
-
count++;
|
|
1379
|
-
if (count === urls) {
|
|
1380
|
-
done();
|
|
1381
|
-
}
|
|
1382
|
-
});
|
|
1383
|
-
|
|
1384
|
-
result
|
|
1385
|
-
.then(function () {
|
|
1386
|
-
assert.ok(true);
|
|
1387
|
-
})
|
|
1388
|
-
.catch(function (err) {
|
|
1389
|
-
assert.fail(`Run should not fail: ${err.toString()}`);
|
|
1390
|
-
});
|
|
1391
|
-
});
|
|
1392
|
-
|
|
1393
|
-
it("should return false if a snapshot can't be created",
|
|
1394
|
-
function (done) {
|
|
1395
|
-
let aborted = false;
|
|
1396
|
-
let count = 0;
|
|
1397
|
-
const argOne = "/services/test/arg/one";
|
|
1398
|
-
const hash = "/services/hash";
|
|
1399
|
-
const pages = !globalUrl ? {
|
|
1400
|
-
// this causes the problem
|
|
1401
|
-
//"http://northstar.local/": "/",
|
|
1402
|
-
"http://northstar.local/contact": "/contact",
|
|
1403
|
-
"http://northstar.local/services/carpets": "/services/carpets",
|
|
1404
|
-
"http://northstar.local/services/test?arg=one": argOne,
|
|
1405
|
-
"https://northstar.local/services/#hash": hash
|
|
1406
|
-
} : {
|
|
1407
|
-
// this causes the problem
|
|
1408
|
-
//"/": "/",
|
|
1409
|
-
"/contact": "/contact",
|
|
1410
|
-
"/services/carpets": "/services/carpets",
|
|
1411
|
-
"/services/test?arg=one": argOne,
|
|
1412
|
-
"/services/#hash": hash
|
|
1413
|
-
};
|
|
1414
|
-
|
|
1415
|
-
gen.run(options.decorate({
|
|
1416
|
-
source: source,
|
|
1417
|
-
outputDir: thisOutputDir,
|
|
1418
|
-
_abort: function (err) {
|
|
1419
|
-
assert.equal(!!err, true);
|
|
1420
|
-
aborted = true;
|
|
1421
|
-
done();
|
|
1422
|
-
},
|
|
1423
|
-
outputPath: function (p) {
|
|
1424
|
-
return pages[p];
|
|
1425
|
-
}
|
|
1426
|
-
}), function (input) {
|
|
1427
|
-
if (!aborted) {
|
|
1428
|
-
const re = new RegExp("("+urlToPathRe(pages[input.__page])+")");
|
|
1429
|
-
const match = re.exec(input.outputFile);
|
|
1430
|
-
assert.equal(match[1], urlToPath(pages[input.__page]));
|
|
1431
|
-
count++;
|
|
1432
|
-
if (count === (urls-1)) {
|
|
1433
|
-
done();
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
|
|
1438
|
-
// for sitemap-gzip, result is true because it doesn't know yet
|
|
1439
|
-
//assert.equal(false, result);
|
|
1440
|
-
});
|
|
1441
|
-
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
});
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1447
|
-
});
|