mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 08:27:03 +02:00
* feat(v2): generate sitemap * cannot snapshot sitemap because xml generated in different order
44 lines
2.5 KiB
JavaScript
44 lines
2.5 KiB
JavaScript
import '@babel/polyfill';
|
|
import createSitemap from '@lib/core/sitemap';
|
|
import loadSetup from '../loadSetup';
|
|
|
|
describe('sitemap', () => {
|
|
test('simple site', async () => {
|
|
const props = await loadSetup('simple');
|
|
const sitemap = await createSitemap(props);
|
|
expect(sitemap).toContain(
|
|
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
|
);
|
|
});
|
|
|
|
test('translated site', async () => {
|
|
const props = await loadSetup('translated');
|
|
const sitemap = await createSitemap(props);
|
|
expect(sitemap).toContain(
|
|
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
|
);
|
|
});
|
|
|
|
test('versioned site', async () => {
|
|
const props = await loadSetup('versioned');
|
|
const sitemap = await createSitemap(props);
|
|
expect(sitemap).toContain(
|
|
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
|
);
|
|
});
|
|
|
|
test('translated + versioned site', async () => {
|
|
const props = await loadSetup('transversioned');
|
|
const sitemap = await createSitemap(props);
|
|
expect(sitemap).toContain(
|
|
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
|
);
|
|
});
|
|
|
|
test('empty site', async () => {
|
|
const props = await loadSetup('empty');
|
|
expect(createSitemap(props)).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
`"Url in siteConfig.js cannot be empty/undefined"`,
|
|
);
|
|
});
|
|
});
|