Skip to content

Commit

Permalink
test(test): add tests for new checks
Browse files Browse the repository at this point in the history
  • Loading branch information
CBW2007 committed Jan 22, 2022
1 parent 343ef17 commit de60c95
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand All @@ -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', {
Expand All @@ -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()

0 comments on commit de60c95

Please sign in to comment.