diff options
author | 2024-06-27 12:50:51 +0100 | |
---|---|---|
committer | 2024-06-27 12:50:51 +0100 | |
commit | 7eea21b3c6ea585027053a700874eb025afd34ad (patch) | |
tree | b63c89967db2b41d4ca3c11363a2b4afe63a5319 /packages/integrations/netlify/test/functions/cookies.test.js | |
parent | f1c389d39ce0493ab075d514ebc9a2e664e19225 (diff) | |
download | astro-7eea21b3c6ea585027053a700874eb025afd34ad.tar.gz astro-7eea21b3c6ea585027053a700874eb025afd34ad.tar.zst astro-7eea21b3c6ea585027053a700874eb025afd34ad.zip |
perf(netlify): handle dependency tracing for SSR function (#296)
* perf: take over function bundling
* Fix test failures
* Format
* Changeset
* Use shared fs helper
* Format
* Changes from review
* Add logging
* Test timeout
* Use posix path
* Remove logs
Diffstat (limited to 'packages/integrations/netlify/test/functions/cookies.test.js')
-rw-r--r-- | packages/integrations/netlify/test/functions/cookies.test.js | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js index c4384f8e0..08a9da8ce 100644 --- a/packages/integrations/netlify/test/functions/cookies.test.js +++ b/packages/integrations/netlify/test/functions/cookies.test.js @@ -2,46 +2,52 @@ import * as assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import { loadFixture } from '@astrojs/test-utils'; -describe('Cookies', () => { - let fixture; +describe( + 'Cookies', + () => { + let fixture; - before(async () => { - fixture = await loadFixture({ root: new URL('./fixtures/cookies/', import.meta.url) }); - await fixture.build(); - }); + before(async () => { + fixture = await loadFixture({ root: new URL('./fixtures/cookies/', import.meta.url) }); + await fixture.build(); + }); - it('Can set multiple', async () => { - const entryURL = new URL( - './fixtures/cookies/.netlify/functions-internal/ssr/ssr.mjs', - import.meta.url - ); - const { default: handler } = await import(entryURL); - const resp = await handler( - new Request('http://example.com/login', { method: 'POST', body: '{}' }), - {} - ); - assert.equal(resp.status, 301); - assert.equal(resp.headers.get('location'), '/'); - assert.deepEqual(resp.headers.getSetCookie(), ['foo=foo; HttpOnly', 'bar=bar; HttpOnly']); - }); + it('Can set multiple', async () => { + const entryURL = new URL( + './fixtures/cookies/.netlify/functions-internal/ssr/ssr.mjs', + import.meta.url + ); + const { default: handler } = await import(entryURL); + const resp = await handler( + new Request('http://example.com/login', { method: 'POST', body: '{}' }), + {} + ); + assert.equal(resp.status, 301); + assert.equal(resp.headers.get('location'), '/'); + assert.deepEqual(resp.headers.getSetCookie(), ['foo=foo; HttpOnly', 'bar=bar; HttpOnly']); + }); - it('renders dynamic 404 page', async () => { - const entryURL = new URL( - './fixtures/cookies/.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', { - headers: { - 'x-test': 'bar', - }, - }), - {} - ); - assert.equal(resp.status, 404); - const text = await resp.text(); - assert.equal(text.includes('This is my custom 404 page'), true); - assert.equal(text.includes('x-test: bar'), true); - }); -}); + it('renders dynamic 404 page', async () => { + const entryURL = new URL( + './fixtures/cookies/.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', { + headers: { + 'x-test': 'bar', + }, + }), + {} + ); + assert.equal(resp.status, 404); + const text = await resp.text(); + assert.equal(text.includes('This is my custom 404 page'), true); + assert.equal(text.includes('x-test: bar'), true); + }); + }, + { + timeout: 120000, + } +); |