Skip to content

Commit

Permalink
test(node): add base route test in trailing-slash.js
Browse files Browse the repository at this point in the history
detected an infinite loop in base path when trailingSlash: never
  • Loading branch information
msxdan committed Dec 9, 2023
1 parent 04cfe02 commit cd13dd6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Index</title>
</head>
<body>
<h1>Index</h1>
</body>
</html>
54 changes: 54 additions & 0 deletions packages/integrations/node/test/trailing-slash.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with redirect', async () => {
const res = await fetch(`http://${server.host}:${server.port}/some-base/one`, {
redirect : 'manual'
Expand Down Expand Up @@ -89,6 +98,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with redirect', async () => {
const res = await fetch(`http://${server.host}:${server.port}/one`, {
redirect : 'manual'
Expand Down Expand Up @@ -140,6 +158,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with redirect', async () => {
const res = await fetch(`http://${server.host}:${server.port}/some-base/one/`, {
redirect : 'manual'
Expand Down Expand Up @@ -189,6 +216,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with redirect', async () => {
const res = await fetch(`http://${server.host}:${server.port}/one/`, {
redirect : 'manual'
Expand Down Expand Up @@ -241,6 +277,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with slash', async () => {
const res = await fetch(`http://${server.host}:${server.port}/some-base/one/`, {
redirect : 'manual'
Expand Down Expand Up @@ -308,6 +353,15 @@ describe('Trailing slash', () => {
delete process.env.PRERENDER;
});

it('Can render prerendered base route', async () => {
const res = await fetch(`http://${server.host}:${server.port}`);
const html = await res.text();
const $ = cheerio.load(html);

expect(res.status).to.equal(200);
expect($('h1').text()).to.equal('Index');
});

it('Can render prerendered route with slash', async () => {
const res = await fetch(`http://${server.host}:${server.port}/one/`);
const html = await res.text();
Expand Down

0 comments on commit cd13dd6

Please sign in to comment.