staticPaths.test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { loadFixture, readXML } from './test-utils.js';
  2. import assert from 'node:assert/strict';
  3. import { before, describe, it } from 'node:test';
  4. describe('getStaticPaths support', () => {
  5. /** @type {import('./test-utils.js').Fixture} */
  6. let fixture;
  7. /** @type {string[]} */
  8. let urls;
  9. before(async () => {
  10. fixture = await loadFixture({
  11. root: './fixtures/static/',
  12. trailingSlash: 'always',
  13. });
  14. await fixture.build();
  15. const data = await readXML(fixture.readFile('/sitemap-0.xml'));
  16. urls = data.urlset.url.map((url) => url.loc[0]);
  17. });
  18. it('requires zero config for getStaticPaths', async () => {
  19. assert.equal(urls.includes('http://example.com/one/'), true);
  20. assert.equal(urls.includes('http://example.com/two/'), true);
  21. });
  22. it('does not include 404 pages', () => {
  23. assert.equal(urls.includes('http://example.com/404/'), false);
  24. });
  25. it('does not include nested 404 pages', () => {
  26. assert.equal(urls.includes('http://example.com/de/404/'), false);
  27. });
  28. it('includes numerical pages', () => {
  29. assert.equal(urls.includes('http://example.com/123/'), true);
  30. });
  31. it('should render the endpoint', async () => {
  32. const page = await fixture.readFile('./it/manifest');
  33. assert.match(page, /I'm a route in the "it" language./);
  34. });
  35. });