Skip to content

Commit

Permalink
integration(sitemap): add unit test for ssr support
Browse files Browse the repository at this point in the history
  • Loading branch information
atilafassina committed May 2, 2023
1 parent 77b0e1d commit 4e00db6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/integrations/sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"zod": "^3.17.3"
},
"devDependencies": {
"@astrojs/node": "workspace:*",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"chai": "^4.3.6",
Expand Down
12 changes: 12 additions & 0 deletions packages/integrations/sitemap/test/fixtures/ssr/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import nodeServer from '@astrojs/node'

export default defineConfig({
integrations: [sitemap()],
site: 'http://example.com',
output: 'server',
adapter: nodeServer({
mode: "standalone"
})
})
9 changes: 9 additions & 0 deletions packages/integrations/sitemap/test/fixtures/ssr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@test/sitemap-trailing-slash",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/sitemap": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>One</title>
</head>
<body>
<h1>One</h1>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Two</title>
</head>
<body>
<h1>Two</h1>
</body>
</html>
22 changes: 22 additions & 0 deletions packages/integrations/sitemap/test/ssr.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { loadFixture, readXML } from './test-utils.js';
import { expect } from 'chai';

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

before(async () => {
fixture = await loadFixture({
root: './fixtures/ssr/',
});
await fixture.build();
});

it('SSR pages require zero config', async () => {
const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
const urls = data.urlset.url;

expect(urls[0].loc[0]).to.equal('http://example.com/one/');
expect(urls[1].loc[0]).to.equal('http://example.com/two/');
});
});
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 4e00db6

Please sign in to comment.