base-path.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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('URLs with base path', () => {
  5. /** @type {import('./test-utils').Fixture} */
  6. let fixture;
  7. describe('using node adapter', () => {
  8. before(async () => {
  9. fixture = await loadFixture({
  10. root: './fixtures/ssr/',
  11. base: '/base',
  12. });
  13. await fixture.build();
  14. });
  15. it('Base path is concatenated correctly', async () => {
  16. const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
  17. const urls = data.urlset.url;
  18. assert.equal(urls[0].loc[0], 'http://example.com/base/one/');
  19. });
  20. });
  21. describe('static', () => {
  22. before(async () => {
  23. fixture = await loadFixture({
  24. root: './fixtures/static/',
  25. base: '/base',
  26. });
  27. await fixture.build();
  28. });
  29. it('Base path is concatenated correctly', async () => {
  30. const data = await readXML(fixture.readFile('/sitemap-0.xml'));
  31. const urls = data.urlset.url;
  32. assert.equal(urls[0].loc[0], 'http://example.com/base/123/');
  33. });
  34. });
  35. });