Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderniebuhr authored and astrobot-houston committed Feb 1, 2024
1 parent 06bae52 commit 08a3e06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
5 changes: 4 additions & 1 deletion packages/netlify/src/ssr-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const clientAddressSymbol = Symbol.for('astro.clientAddress');
export const createExports = (manifest: SSRManifest, _args: Args) => {
const app = new App(manifest);

function createHandler(integrationConfig: { cacheOnDemandPages: boolean, notFoundContent?: string }) {
function createHandler(integrationConfig: {
cacheOnDemandPages: boolean;
notFoundContent?: string;
}) {
return async function handler(request: Request, context: Context) {
const routeData = app.match(request);
if (!routeData && typeof integrationConfig.notFoundContent !== 'undefined') {
Expand Down
14 changes: 7 additions & 7 deletions packages/netlify/test/functions/cookies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Cookies', () => {
expect(resp.headers.getSetCookie()).to.eql(['foo=foo; HttpOnly', 'bar=bar; HttpOnly']);
});

it("renders dynamic 404 page", async () => {
it('renders dynamic 404 page', async () => {
const entryURL = new URL(
'./fixtures/cookies/.netlify/functions-internal/ssr/ssr.mjs',
import.meta.url
Expand All @@ -33,14 +33,14 @@ describe('Cookies', () => {
const resp = await handler(
new Request('http://example.com/nonexistant-page', {
headers: {
"x-test": "bar"
}
'x-test': 'bar',
},
}),
{}
);
expect(resp.status).to.equal(404);
const text = await resp.text()
expect(text).to.contain("This is my custom 404 page");
expect(text).to.contain("x-test: bar");
})
const text = await resp.text();
expect(text).to.contain('This is my custom 404 page');
expect(text).to.contain('x-test: bar');
});
});
36 changes: 15 additions & 21 deletions packages/netlify/test/functions/redirects.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer } from 'http';
import { loadFixture } from '@astrojs/test-utils';
import { expect } from 'chai';
import { createServer } from 'http';

describe('SSR - Redirects', () => {
let fixture;
Expand All @@ -27,40 +27,34 @@ describe('SSR - Redirects', () => {
expect(hasErrored).to.equal(true, 'this file should not exist');
});

it("renders static 404 page", async () => {
it('renders static 404 page', async () => {
const entryURL = new URL(
'./fixtures/redirects/.netlify/functions-internal/ssr/ssr.mjs',
import.meta.url
);
const { default: handler } = await import(entryURL);
const resp = await handler(
new Request('http://example.com/nonexistant-page', ),
{}
);
const resp = await handler(new Request('http://example.com/nonexistant-page'), {});
expect(resp.status).to.equal(404);
const text = await resp.text()
expect(text).to.contain("This is my static 404 page");
})
const text = await resp.text();
expect(text).to.contain('This is my static 404 page');
});

it('does not pass through 404 request', async () => {
let testServerCalls = 0
let testServerCalls = 0;
const testServer = createServer((req, res) => {
testServerCalls++
res.writeHead(200)
res.end()
})
testServer.listen(5678)
testServerCalls++;
res.writeHead(200);
res.end();
});
testServer.listen(5678);
const entryURL = new URL(
'./fixtures/redirects/.netlify/functions-internal/ssr/ssr.mjs',
import.meta.url
);
const { default: handler } = await import(entryURL);
const resp = await handler(
new Request('http://localhost:5678/nonexistant-page'),
{}
);
const resp = await handler(new Request('http://localhost:5678/nonexistant-page'), {});
expect(resp.status).to.equal(404);
expect(testServerCalls).to.equal(0)
testServer.close()
expect(testServerCalls).to.equal(0);
testServer.close();
});
});

0 comments on commit 08a3e06

Please sign in to comment.