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,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "html-snapshots-example",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"author": "Alex Grant <alex@localnerve.com>",
|
|
5
|
-
"description": "An example using html-snapshots",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start": "node ./snapshot.js"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"html-snapshots": "^1.0.1"
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Snapshot an example website.
|
|
3
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
4
|
-
*
|
|
5
|
-
* Use sitemap.xml to snapshot an entire site.
|
|
6
|
-
* Use the verbose option to debug the loading of one of the pages.
|
|
7
|
-
*/
|
|
8
|
-
const htmlSnapshots = require("html-snapshots");
|
|
9
|
-
|
|
10
|
-
const origin = "https://www.sitemaps.org";
|
|
11
|
-
const pageToDebug = `${origin}/en_GB/`;
|
|
12
|
-
|
|
13
|
-
// Make the verbose option as an object keyed with the page to debug.
|
|
14
|
-
const verboseOption = {
|
|
15
|
-
__default: false,
|
|
16
|
-
[pageToDebug]: true
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
htmlSnapshots.run({
|
|
20
|
-
input: "sitemap",
|
|
21
|
-
source: `${origin}/sitemap.xml`,
|
|
22
|
-
outputDir: require("path").join(__dirname, "./tmp"),
|
|
23
|
-
outputDirClean: true,
|
|
24
|
-
selector: "#mainContent",
|
|
25
|
-
timeout: 10000,
|
|
26
|
-
browser: "phantomjs",
|
|
27
|
-
processLimit: 1, // to clarify output
|
|
28
|
-
verbose: verboseOption
|
|
29
|
-
})
|
|
30
|
-
.then(completed => {
|
|
31
|
-
console.log("completed snapshots:");
|
|
32
|
-
console.log(require("util").inspect(completed));
|
|
33
|
-
})
|
|
34
|
-
.catch(console.error);
|
package/test/helpers/options.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* options.js
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*
|
|
6
|
-
* A test helper to decorate html-snapshots options
|
|
7
|
-
*
|
|
8
|
-
* phantomjs
|
|
9
|
-
* If a global phantomjs is defined, decorates html-snapshots options to specify that global
|
|
10
|
-
* In some test environments (travis), local phantomjs will not install if a global is found.
|
|
11
|
-
*/
|
|
12
|
-
const assert = require("assert");
|
|
13
|
-
|
|
14
|
-
// @0.12.0, on Travis-ci phantomjs2 WILL install local WITH the older global.
|
|
15
|
-
// So reverting back to decorateLocal only.
|
|
16
|
-
// THIS COULD CHANGE... stay on top.
|
|
17
|
-
|
|
18
|
-
// abort is now required, so if one not supplied, supply a default.
|
|
19
|
-
function fillAbort (options) {
|
|
20
|
-
if (!options._abort) {
|
|
21
|
-
options._abort = function (err) {
|
|
22
|
-
const msg = `[options._abort] called: ${err.toString()}`;
|
|
23
|
-
console.log(`@@@ ${msg}`);
|
|
24
|
-
assert.fail(msg);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/*
|
|
29
|
-
var spawn = require("child_process").spawn;
|
|
30
|
-
|
|
31
|
-
function decorateGlobal (options) {
|
|
32
|
-
options.phantomjs = "phantomjs";
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
35
|
-
*/
|
|
36
|
-
function decorateLocal(options) {
|
|
37
|
-
// local is the default
|
|
38
|
-
fillAbort(options);
|
|
39
|
-
return options;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
var cp = spawn("phantomjs", ["--version"]);
|
|
44
|
-
cp.on("error", function(err) {
|
|
45
|
-
module.exports.decorate = decorateLocal;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
49
|
-
decorate: decorateGlobal
|
|
50
|
-
};
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
decorate: decorateLocal
|
|
55
|
-
};
|
package/test/helpers/result.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Asserts error is error.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
var assert = require("assert");
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* NodeJS v8 ifError throws if value is truthy
|
|
10
|
-
* NodeJS v10 ifError throws if value is NOT undefined or null.
|
|
11
|
-
* So to cover both, added falsy check.
|
|
12
|
-
*
|
|
13
|
-
* @param {*} err
|
|
14
|
-
*/
|
|
15
|
-
function notFalsy (err) {
|
|
16
|
-
return !!err;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function mustBeError (err) {
|
|
20
|
-
assert.throws(
|
|
21
|
-
function () {
|
|
22
|
-
notFalsy(err) && assert.ifError(err);
|
|
23
|
-
},
|
|
24
|
-
function (err) {
|
|
25
|
-
return !!err;
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = {
|
|
31
|
-
mustBeError: mustBeError
|
|
32
|
-
};
|
package/test/helpers/sitemap.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Helper to add dynamic url nodes to a test sitemap.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
var smLib = require("sitemap-xml");
|
|
7
|
-
var urlLib = require("url");
|
|
8
|
-
var fs = require("fs");
|
|
9
|
-
var pathLib = require("path");
|
|
10
|
-
var _ = require("lodash");
|
|
11
|
-
var mkdirp = require("mkdirp").sync;
|
|
12
|
-
var base = require("../../lib/input-generators/_base");
|
|
13
|
-
|
|
14
|
-
var now = new Date();
|
|
15
|
-
var outofDate = "2013-05-01T00:00:00.000Z";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The sitemap element enum
|
|
19
|
-
* Indicates which optional sitemap policy elements are missing.
|
|
20
|
-
* 0 means no policy elements are missing
|
|
21
|
-
* 1 means lastmod policy element is missing
|
|
22
|
-
* 2 means changefreq policy element is missing
|
|
23
|
-
* 3 means all policy elements missing
|
|
24
|
-
*/
|
|
25
|
-
var smElement = {
|
|
26
|
-
none: 0,
|
|
27
|
-
lastMod: 1,
|
|
28
|
-
changeFreq: 2,
|
|
29
|
-
all: 3
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* `current` is a boolean that indicates if the policy should be current
|
|
34
|
-
* `missing` can be smElement value.
|
|
35
|
-
*
|
|
36
|
-
* If lastmod is not missing
|
|
37
|
-
* if current, it is now, else 1/1/2013
|
|
38
|
-
* If changefreq is not missing
|
|
39
|
-
* it is always "weekly"
|
|
40
|
-
*/
|
|
41
|
-
function lastmodChangeFreq(current, missing) {
|
|
42
|
-
var nowDate = now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
|
|
43
|
-
return _.extend({},
|
|
44
|
-
(missing & smElement.lastMod) ? {} : { lastmod: current ? nowDate : outofDate },
|
|
45
|
-
(missing & smElement.changeFreq) ? {} : { changefreq: "weekly" }
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* format a urlset.url.loc from a url path
|
|
51
|
-
*/
|
|
52
|
-
function makeLoc(url) {
|
|
53
|
-
return urlLib.format({
|
|
54
|
-
protocol: "http",
|
|
55
|
-
host: "localhost",
|
|
56
|
-
pathname: url
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Builds a sitemap with localhost urls and stores it at `path`.
|
|
62
|
-
* Creates the sitemap with `urls`, `current` of which will be current by policy
|
|
63
|
-
* `missing` can be smElement value.
|
|
64
|
-
* All urls are given the priority of 0.5
|
|
65
|
-
*/
|
|
66
|
-
function buildSitemapWithPolicy(path, urls, current, missing, cb) {
|
|
67
|
-
var sm = smLib();
|
|
68
|
-
|
|
69
|
-
// map given paths to url sitemap nodes
|
|
70
|
-
var urlNodes = urls.map(function(url, index) {
|
|
71
|
-
return _.extend({
|
|
72
|
-
loc: makeLoc(url),
|
|
73
|
-
priority: "0.5"
|
|
74
|
-
},
|
|
75
|
-
lastmodChangeFreq(index < current, missing)
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
//fs.unlinkSync(path);
|
|
80
|
-
var writeStream = fs.createWriteStream(path, { encoding: "utf8" });
|
|
81
|
-
writeStream.on("finish", cb);
|
|
82
|
-
|
|
83
|
-
sm.pipe(writeStream);
|
|
84
|
-
urlNodes.forEach(function(urlNode) {
|
|
85
|
-
sm.write(urlNode);
|
|
86
|
-
});
|
|
87
|
-
sm.end();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Make html output files for a given url set.
|
|
92
|
-
* The `urlset` is an array of objects that are: { loc: <url>, lastmod: <Date> }
|
|
93
|
-
* This mocks output from a previous run and sets a,mtimes for the files.
|
|
94
|
-
*/
|
|
95
|
-
function makeOutputFiles(options, urlset) {
|
|
96
|
-
var html = "<!doctype html><html><head><title>test</title></head><body><h1>Hello World</h1><p>This is a test</p</body>";
|
|
97
|
-
var filePath, outputDir;
|
|
98
|
-
|
|
99
|
-
urlset.forEach(function(urlObj) {
|
|
100
|
-
filePath = base.outputFile(options, urlObj.loc);
|
|
101
|
-
outputDir = pathLib.dirname(filePath);
|
|
102
|
-
|
|
103
|
-
if (!fs.existsSync()) {
|
|
104
|
-
mkdirp(outputDir);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
fs.writeFileSync(filePath, html, { encoding: "utf8"});
|
|
108
|
-
fs.utimesSync(filePath, urlObj.lastmod, urlObj.lastmod);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Mock pre-existing output files for comparisons.
|
|
114
|
-
*/
|
|
115
|
-
function buildTestFiles(options, urls, current) {
|
|
116
|
-
|
|
117
|
-
makeOutputFiles(options, urls.map(function(url, index) {
|
|
118
|
-
return {
|
|
119
|
-
loc: makeLoc(url),
|
|
120
|
-
// always make the out of date file a little older than the outofDate sitemap
|
|
121
|
-
lastmod: index < current ? now : new Date(Date.parse(outofDate) - 10000)
|
|
122
|
-
};
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = {
|
|
127
|
-
smElement: smElement,
|
|
128
|
-
buildSitemapWithPolicy: buildSitemapWithPolicy,
|
|
129
|
-
buildTestFiles: buildTestFiles
|
|
130
|
-
};
|
package/test/mocha/async/test.js
DELETED
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Async module tests.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global describe, beforeEach, it */
|
|
7
|
-
var assert = require("assert");
|
|
8
|
-
var fs = require("fs");
|
|
9
|
-
var path = require("path");
|
|
10
|
-
var mkdirp = require("mkdirp");
|
|
11
|
-
var rimraf = require("rimraf").sync;
|
|
12
|
-
var asyncLib = require("async");
|
|
13
|
-
var asyncLocal = require("../../../lib/async");
|
|
14
|
-
|
|
15
|
-
var Notifier = asyncLocal.Notifier;
|
|
16
|
-
|
|
17
|
-
describe("async", function () {
|
|
18
|
-
|
|
19
|
-
describe("Notifier", function () {
|
|
20
|
-
var notifier;
|
|
21
|
-
|
|
22
|
-
function createFiles (files) {
|
|
23
|
-
var fd;
|
|
24
|
-
files.forEach(function (file) {
|
|
25
|
-
fd = fs.openSync(file, 'w');
|
|
26
|
-
fs.closeSync(fd);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// create a worker for asyncLib.queue
|
|
31
|
-
function worker(file, timeout) {
|
|
32
|
-
return function (cb) {
|
|
33
|
-
setTimeout(function () {
|
|
34
|
-
fs.close(fs.openSync(file, 'w'), cb);
|
|
35
|
-
}, timeout);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var mockInput = {
|
|
40
|
-
EOI: function () { return true; }
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
beforeEach(function () {
|
|
44
|
-
notifier = new Notifier();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should throw if started more than once", function (done) {
|
|
48
|
-
notifier.start(1000, {}, function () {});
|
|
49
|
-
|
|
50
|
-
assert.throws(function () {
|
|
51
|
-
notifier.start(100, {}, function () {});
|
|
52
|
-
}, function (err) {
|
|
53
|
-
assert.ok(err instanceof Error);
|
|
54
|
-
done();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should throw if add called before start", function (done) {
|
|
59
|
-
assert.throws(function () {
|
|
60
|
-
notifier.add();
|
|
61
|
-
}, function (err) {
|
|
62
|
-
assert.ok(err instanceof Error);
|
|
63
|
-
done();
|
|
64
|
-
})
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should be able to start and watch files get created", function (done) {
|
|
68
|
-
var dir = path.join(__dirname, "./files"),
|
|
69
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
70
|
-
pollCount = 4,
|
|
71
|
-
timeout = 100,
|
|
72
|
-
start;
|
|
73
|
-
|
|
74
|
-
rimraf(dir);
|
|
75
|
-
|
|
76
|
-
// take the worker queue out of the equation
|
|
77
|
-
notifier.qEmpty();
|
|
78
|
-
|
|
79
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
80
|
-
// make sure this wasn't called because of a timeout/failure
|
|
81
|
-
assert.equal(true, (Date.now() - start) < (timeout+asyncLocal.TIMEOUT_PAD_FLOOR));
|
|
82
|
-
|
|
83
|
-
// compare filesDone to input files
|
|
84
|
-
if (typeof err === "undefined") {
|
|
85
|
-
files.sort();
|
|
86
|
-
filesDone.sort();
|
|
87
|
-
assert.deepEqual(files, filesDone);
|
|
88
|
-
|
|
89
|
-
// audit paths
|
|
90
|
-
//console.log("filesDone paths:");
|
|
91
|
-
//for (var k=0; k < filesDone.length; k++) {
|
|
92
|
-
// console.log(filesDone);
|
|
93
|
-
//}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
done(err);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
mkdirp.sync(dir);
|
|
100
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
101
|
-
|
|
102
|
-
files.forEach(function (file) {
|
|
103
|
-
notifier.add(file, timeout);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
assert.equal(files.length, notifier._fileCount());
|
|
107
|
-
assert.equal(true, notifier.isStarted());
|
|
108
|
-
|
|
109
|
-
start = Date.now();
|
|
110
|
-
createFiles(files);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should be able to start and watch files get created, remove one from the list",
|
|
114
|
-
function (done) {
|
|
115
|
-
var dir = path.join(__dirname, "./files"),
|
|
116
|
-
filesToDo = [],
|
|
117
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
118
|
-
pollCount = 4,
|
|
119
|
-
timeout = 100,
|
|
120
|
-
start;
|
|
121
|
-
|
|
122
|
-
rimraf(dir);
|
|
123
|
-
|
|
124
|
-
// take the worker queue out of the equation
|
|
125
|
-
notifier.qEmpty();
|
|
126
|
-
|
|
127
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
128
|
-
// make sure this wasn't called because of a timeout/failure
|
|
129
|
-
assert.equal(true, (Date.now() - start) < (timeout+asyncLocal.TIMEOUT_PAD_FLOOR));
|
|
130
|
-
|
|
131
|
-
// compare filesDone to input files
|
|
132
|
-
if (typeof err === "undefined") {
|
|
133
|
-
filesToDo.sort();
|
|
134
|
-
filesDone.sort();
|
|
135
|
-
assert.deepEqual(filesToDo, filesDone);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
done(err);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
mkdirp.sync(dir);
|
|
142
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
143
|
-
|
|
144
|
-
files.forEach(function(file) {
|
|
145
|
-
notifier.add(file, timeout);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
notifier.remove(files[2]);
|
|
149
|
-
filesToDo.push(files[0], files[1]);
|
|
150
|
-
|
|
151
|
-
assert.equal(files.length-1, notifier._fileCount());
|
|
152
|
-
assert.equal(true, notifier.isStarted());
|
|
153
|
-
|
|
154
|
-
start = Date.now();
|
|
155
|
-
createFiles(files);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("should be able to start and watch files get created, one doesn't get created",
|
|
159
|
-
function (done) {
|
|
160
|
-
var dir = path.join(__dirname, "./files"),
|
|
161
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
162
|
-
filesToDo = files.slice(),
|
|
163
|
-
pollCount = 4,
|
|
164
|
-
timeout = 100,
|
|
165
|
-
start;
|
|
166
|
-
|
|
167
|
-
rimraf(dir);
|
|
168
|
-
|
|
169
|
-
// take the worker queue out of the equation
|
|
170
|
-
notifier.qEmpty();
|
|
171
|
-
|
|
172
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
173
|
-
// make sure this was called because of a failure
|
|
174
|
-
assert.equal(true, (Date.now() - start) > (timeout+asyncLocal.TIMEOUT_PAD_FLOOR));
|
|
175
|
-
// make sure this was a failure
|
|
176
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
177
|
-
|
|
178
|
-
// compare filesDone to intended filesToDo - should be different
|
|
179
|
-
filesToDo.sort();
|
|
180
|
-
filesDone.sort();
|
|
181
|
-
assert.notDeepEqual(filesToDo, filesDone);
|
|
182
|
-
|
|
183
|
-
// compare filesDone to files - should be the same
|
|
184
|
-
files.sort();
|
|
185
|
-
assert.deepEqual(files, filesDone);
|
|
186
|
-
|
|
187
|
-
done();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
mkdirp.sync(dir);
|
|
191
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
192
|
-
|
|
193
|
-
files.forEach(function (file) {
|
|
194
|
-
notifier.add(file, timeout);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
assert.equal(files.length, notifier._fileCount());
|
|
198
|
-
assert.equal(true, notifier.isStarted());
|
|
199
|
-
|
|
200
|
-
files.splice(1, 1); // remove the second element
|
|
201
|
-
|
|
202
|
-
start = Date.now();
|
|
203
|
-
createFiles(files);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("should be able to start and watch files get created, none get created",
|
|
207
|
-
function (done) {
|
|
208
|
-
var dir = path.join(__dirname, "./files"),
|
|
209
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
210
|
-
pollCount = 4,
|
|
211
|
-
timeout = 100,
|
|
212
|
-
start;
|
|
213
|
-
|
|
214
|
-
rimraf(dir);
|
|
215
|
-
|
|
216
|
-
// take the worker queue out of the equation
|
|
217
|
-
notifier.qEmpty();
|
|
218
|
-
|
|
219
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
220
|
-
var assertionError;
|
|
221
|
-
try {
|
|
222
|
-
assert.equal(true, (Date.now() - start) > (timeout+asyncLocal.TIMEOUT_PAD_FLOOR));
|
|
223
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
224
|
-
assert.equal(0, filesDone.length);
|
|
225
|
-
} catch (e) {
|
|
226
|
-
assertionError = e;
|
|
227
|
-
}
|
|
228
|
-
done(assertionError);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
mkdirp.sync(dir);
|
|
232
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
233
|
-
|
|
234
|
-
files.forEach(function (file) {
|
|
235
|
-
notifier.add(file, timeout);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
assert.equal(files.length, notifier._fileCount());
|
|
239
|
-
assert.equal(true, notifier.isStarted());
|
|
240
|
-
start = Date.now();
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it("should fail if no callback supplied", function () {
|
|
244
|
-
var result = notifier.start(1, mockInput);
|
|
245
|
-
|
|
246
|
-
assert.equal(result, false);
|
|
247
|
-
assert.equal(0, notifier._fileCount());
|
|
248
|
-
assert.equal(false, notifier.isStarted());
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("should fail if negative poll interval supplied", function () {
|
|
252
|
-
var result = notifier.start(-1, mockInput, function (err) {
|
|
253
|
-
assert.fail(err, "[not undefined]", "should never have been called", "?");
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
assert.equal(result, false);
|
|
257
|
-
assert.equal(0, notifier._fileCount());
|
|
258
|
-
assert.equal(false, notifier.isStarted());
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it("should fail if zero poll interval supplied", function () {
|
|
262
|
-
var result = notifier.start(0, mockInput, function (err){
|
|
263
|
-
assert.fail(err, "[not undefined]", "should never have been called", "?");
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
assert.equal(result, false);
|
|
267
|
-
assert.equal(0, notifier._fileCount());
|
|
268
|
-
assert.equal(false, notifier.isStarted());
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it("should fail if no input generator is supplied", function () {
|
|
272
|
-
var result = notifier.start(250, undefined, function (err) {
|
|
273
|
-
assert.fail(err, "[not undefined]", "should never have been called", "?");
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
assert.equal(result, false);
|
|
277
|
-
assert.equal(0, notifier._fileCount());
|
|
278
|
-
assert.equal(false, notifier.isStarted());
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("should abort if requested, no files done yet", function (done) {
|
|
282
|
-
var dir = path.join(__dirname, "./files"),
|
|
283
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
284
|
-
pollCount = 4,
|
|
285
|
-
timeout = 400,
|
|
286
|
-
abortFailure = new Error("abortFailure");
|
|
287
|
-
|
|
288
|
-
rimraf(dir);
|
|
289
|
-
|
|
290
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
291
|
-
// make sure this was a failure
|
|
292
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
293
|
-
|
|
294
|
-
// make sure we got the expected err
|
|
295
|
-
assert.equal(err, abortFailure);
|
|
296
|
-
|
|
297
|
-
// and that no files were done
|
|
298
|
-
assert.equal(filesDone.length, 0);
|
|
299
|
-
|
|
300
|
-
done();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
mkdirp.sync(dir);
|
|
304
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
305
|
-
|
|
306
|
-
files.forEach(function (file) {
|
|
307
|
-
notifier.add(file, timeout);
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
assert.equal(files.length, notifier._fileCount());
|
|
311
|
-
assert.equal(true, notifier.isStarted());
|
|
312
|
-
|
|
313
|
-
notifier.abort({ length: function () { return 0; } }, abortFailure);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it("should abort if requested, all but one file processed", function (done) {
|
|
317
|
-
var dir = path.join(__dirname, "./files"),
|
|
318
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
319
|
-
filesToDo = files.slice(),
|
|
320
|
-
pollCount = 8,
|
|
321
|
-
timeout = 400,
|
|
322
|
-
abortFailure = new Error("abortFailure");
|
|
323
|
-
|
|
324
|
-
rimraf(dir);
|
|
325
|
-
|
|
326
|
-
notifier.start(timeout / pollCount, mockInput, function (err, filesDone) {
|
|
327
|
-
// make sure this was a failure
|
|
328
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
329
|
-
|
|
330
|
-
// make sure we got the expected err
|
|
331
|
-
assert.equal(err, abortFailure);
|
|
332
|
-
|
|
333
|
-
// and that one file was not done
|
|
334
|
-
assert.equal(filesToDo.length - 1, filesDone.length);
|
|
335
|
-
|
|
336
|
-
done();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
mkdirp.sync(dir);
|
|
340
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
341
|
-
|
|
342
|
-
files.forEach(function (file) {
|
|
343
|
-
notifier.add(file, timeout);
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
assert.equal(files.length, notifier._fileCount());
|
|
347
|
-
assert.equal(true, notifier.isStarted());
|
|
348
|
-
|
|
349
|
-
files.splice(1, 1); // remove the second element
|
|
350
|
-
|
|
351
|
-
createFiles(files);
|
|
352
|
-
|
|
353
|
-
// fake out async.queue here. In reality, q.length() would be 1 normally,
|
|
354
|
-
// but it will never become empty since async.queue doesn't run in this test.
|
|
355
|
-
setTimeout(function () {
|
|
356
|
-
notifier.abort({ length: function() { return 0; } }, abortFailure);
|
|
357
|
-
}, 100);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("should abort if requested, all but one file processed, real async",
|
|
361
|
-
function (done) {
|
|
362
|
-
var dir = path.join(__dirname, "./files"),
|
|
363
|
-
files = [dir+"/one", dir+"/two", dir+"/three"],
|
|
364
|
-
pollCount = 8,
|
|
365
|
-
timeout = 400,
|
|
366
|
-
abortFailure = new Error("abortFailure");
|
|
367
|
-
|
|
368
|
-
rimraf(dir);
|
|
369
|
-
|
|
370
|
-
notifier.start(timeout / pollCount, mockInput, function(err, filesDone) {
|
|
371
|
-
// make sure this was a failure
|
|
372
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
373
|
-
|
|
374
|
-
// make sure we got the expected err
|
|
375
|
-
assert.equal(err, abortFailure);
|
|
376
|
-
|
|
377
|
-
// and that one file was not done
|
|
378
|
-
assert.equal(files.length - 2, filesDone.length);
|
|
379
|
-
|
|
380
|
-
done();
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
mkdirp.sync(dir);
|
|
384
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
385
|
-
|
|
386
|
-
// create a worker queue, attach qEmpty
|
|
387
|
-
var q = asyncLib.queue(function (task, callback) {
|
|
388
|
-
task(callback);
|
|
389
|
-
}, 1);
|
|
390
|
-
q.empty(notifier.qEmpty.bind(notifier));
|
|
391
|
-
|
|
392
|
-
// simulate input activity
|
|
393
|
-
files.forEach(function (file) {
|
|
394
|
-
notifier.add(file, timeout);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
assert.equal(files.length, notifier._fileCount());
|
|
398
|
-
assert.equal(true, notifier.isStarted());
|
|
399
|
-
|
|
400
|
-
// simulate work - files.length workers taking workerTime to complete.
|
|
401
|
-
var workerTime = 40;
|
|
402
|
-
|
|
403
|
-
files.forEach(function (file) {
|
|
404
|
-
q.push(worker(file, workerTime));
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
// call abort in the middle of the second to last worker
|
|
408
|
-
// so files.length - 2 workers should have completed since q.concurrent === 1
|
|
409
|
-
setTimeout(function () {
|
|
410
|
-
notifier.abort(q, abortFailure);
|
|
411
|
-
},
|
|
412
|
-
(workerTime * (files.length-1)) - (workerTime/2)
|
|
413
|
-
);
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
});
|