From de60c95a4f04a2ab7cadd7d09c37bb3348831acb Mon Sep 17 00:00:00 2001 From: CBW2007 <2337118038@qq.com> Date: Sat, 22 Jan 2022 13:27:50 +0800 Subject: [PATCH] test(test): add tests for new checks --- scripts/test.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/test.js b/scripts/test.js index 098ba11..9a7cf87 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -6,7 +6,14 @@ fs.mkdirSync('./public') const MySitemap = new SitemapManager({ siteURL: 'https://example.com/', - pathPrefix: 'aaa' + pathPrefix: 'aaa', + hooks: { + // warningHandler: (msg) => { console.log('#' + msg) }, + /* fileHandler: (file, data) => { + console.log(`===${file}===`) + console.log(data) + } */ + } }) MySitemap.addUrl('dates', [ @@ -17,16 +24,17 @@ MySitemap.addUrl('dates', [ MySitemap.addUrl('freq', [ { loc: 'https://example.com/aaa/b/a', changefreq: 4 }, - { loc: 'https://example.com/aaa/b/c', changefreq: 7 }, - { loc: 'https://example.com/aaa/b/c', changefreq: 'daily' } -// { loc: 'https://example.com/aaa/b/c', changefreq: 'what' } // wrong case + { loc: 'https://example.com/aaa/b/b', changefreq: 7 }/*, + { loc: 'https://example.com/aaa/b/c', changefreq: 'daily' }, + { loc: 'https://example.com/aaa/b/d', changefreq: 114514 }, // wrong case, + { loc: 'https://example.com/aaa/b/e', changefreq: 'what' } // wrong case */ ]) MySitemap.addUrl('pro', [ { loc: 'https://example.com/aaa/c/a', priority: 0.3 }, - { loc: 'https://example.com/aaa/c/c', priority: 0.5 } -// { loc: 'https://example.com/aaa/c/c', priority: 2 }, // wrong case -// { loc: 'https://example.com/aaa/c/c', priority: -1 } // wrong case + { loc: 'https://example.com/aaa/c/b', priority: 0.5 }/*, + { loc: 'https://example.com/aaa/c/c', priority: 2 }, // wrong case + { loc: 'https://example.com/aaa/c/d', priority: -1 } // wrong case */ ]) MySitemap.addUrl('mix', { @@ -48,5 +56,11 @@ MySitemap.addUrl('mix', { lastmod: '2007-03-13T08:00:00', priority: 0.9 }) +/* MySitemap.addUrl('mix', { // repeat case + loc: 'https://example.com/aaa/d/d', + changefreq: 'always', + lastmod: '2007-03-13T08:00:00', + priority: 0.9 +}) */ MySitemap.finish()