You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
883 B
31 lines
883 B
2 years ago
|
const { assert } = require('chai')
|
||
|
const fs = require('fs')
|
||
|
|
||
|
const PagesQuery = require('./../src/queries/pages.js')
|
||
|
const configStore = require('./../src/config.js')
|
||
|
const parseYamlFile = require('./../src/parsers/yaml.js')
|
||
|
const Sitemap = require('./../src/factories/sitemap.js')
|
||
|
|
||
|
describe('Sitemap', function () {
|
||
|
|
||
|
configStore.set('source', './ressources')
|
||
|
configStore.set('destination', './dist')
|
||
|
|
||
|
const file = fs.readFileSync('./ressources/site.yml', 'utf8')
|
||
|
const siteConfig = parseYamlFile(file)
|
||
|
|
||
|
const query = new PagesQuery('./ressources')
|
||
|
const results = query.find()
|
||
|
|
||
|
const sitemap = new Sitemap(siteConfig)
|
||
|
|
||
|
results.forEach((page) => {
|
||
|
sitemap.addPage(page)
|
||
|
})
|
||
|
|
||
|
// check results
|
||
|
it('loc-tag with url', function() {
|
||
|
assert.match(sitemap.getXmlAsString(), /<loc>https:\/\/test.lan\/blog\/article.html<\/loc>/)
|
||
|
})
|
||
|
})
|