diff options
author | 2023-12-17 16:44:09 +0100 | |
---|---|---|
committer | 2023-12-17 16:44:09 +0100 | |
commit | 94dcbfed0607d037c591001b5484de74661c90a2 (patch) | |
tree | 7ecfac03e71d61da8cf9fcf935291fc57e005432 /packages/integrations/netlify/test/functions/cookies.test.js | |
parent | acb92412634176ae32dfbe186bf430055408e8fd (diff) | |
download | astro-94dcbfed0607d037c591001b5484de74661c90a2.tar.gz astro-94dcbfed0607d037c591001b5484de74661c90a2.tar.zst astro-94dcbfed0607d037c591001b5484de74661c90a2.zip |
feat(netlify): Netlify Adapter v4 (#84)
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Jacklyn <70537879+jacklyn-net@users.noreply.github.com>
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <602478+ematipico@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to 'packages/integrations/netlify/test/functions/cookies.test.js')
-rw-r--r-- | packages/integrations/netlify/test/functions/cookies.test.js | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js index c183b34b3..54f776499 100644 --- a/packages/integrations/netlify/test/functions/cookies.test.js +++ b/packages/integrations/netlify/test/functions/cookies.test.js @@ -1,31 +1,23 @@ -import { fileURLToPath } from 'url'; import { expect } from 'chai'; -import { cli } from './test-utils.js'; - -const root = new URL('./fixtures/cookies/', import.meta.url).toString(); +import { loadFixture } from "@astrojs/test-utils" describe('Cookies', () => { + let fixture; + before(async () => { - await cli('build', '--root', fileURLToPath(root)); + 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/entry.mjs', + './fixtures/cookies/.netlify/functions-internal/ssr/ssr.mjs', import.meta.url ); - const { handler } = await import(entryURL); - const resp = await handler({ - httpMethod: 'POST', - headers: {}, - rawUrl: 'http://example.com/login', - body: '{}', - isBase64Encoded: false, - }); - expect(resp.statusCode).to.equal(301); - expect(resp.headers.location).to.equal('/'); - expect(resp.multiValueHeaders).to.be.deep.equal({ - 'set-cookie': ['foo=foo; HttpOnly', 'bar=bar; HttpOnly'], - }); + const { default: handler } = await import(entryURL); + const resp = await handler(new Request('http://example.com/login', { method: "POST", body: '{}' }), {}) + expect(resp.status).to.equal(301); + expect(resp.headers.get("location")).to.equal('/'); + expect(resp.headers.getSetCookie()).to.eql(['foo=foo; HttpOnly', 'bar=bar; HttpOnly']); }); }); |