Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 30, 2024
1 parent 9cb11dd commit c9cd54f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/integrations/sitemap/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const SitemapOptionsSchema = z
filter: z.function().args(z.string()).returns(z.boolean()).optional(),
customPages: z.string().url().array().optional(),
canonicalURL: z.string().url().optional(),
xslURL: z.string().url().optional(),
xslURL: z.string().optional(),

i18n: z
.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { before, describe, it } from 'node:test';
import { sitemap } from './fixtures/static/deps.mjs';
import { loadFixture, readXML } from './test-utils.js';

describe('Filter support', () => {
describe('Config', () => {
/** @type {import('./test-utils.js').Fixture} */
let fixture;

Expand All @@ -14,17 +14,26 @@ describe('Filter support', () => {
integrations: [
sitemap({
filter: (page) => page === 'http://example.com/one/',
xslURL: '/sitemap.xsl',
}),
],
});
await fixture.build();
});

it('Just one page is added', async () => {
it('filter: Just one page is added', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
assert.equal(urls.length, 1);
});

it('xslURL: Includes xml-stylsheet', async () => {
const xml = await fixture.readFile('/sitemap-0.xml');
assert.ok(
xml.includes('<?xml-stylesheet type="text/xsl" href="http://example.com/sitemap.xsl"?>'),
xml,
);
});
});

describe('SSR', () => {
Expand All @@ -34,16 +43,25 @@ describe('Filter support', () => {
integrations: [
sitemap({
filter: (page) => page === 'http://example.com/one/',
xslURL: '/sitemap.xsl',
}),
],
});
await fixture.build();
});

it('Just one page is added', async () => {
it('filter: Just one page is added', async () => {
const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
const urls = data.urlset.url;
assert.equal(urls.length, 1);
});

it('xslURL: Includes xml-stylsheet', async () => {
const xml = await fixture.readFile('/client/sitemap-0.xml');
assert.ok(
xml.includes('<?xml-stylesheet type="text/xsl" href="http://example.com/sitemap.xsl"?>'),
xml,
);
});
});
});
1 change: 0 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9cd54f

Please sign in to comment.