diff options
author | 2023-11-28 15:39:38 +0100 | |
---|---|---|
committer | 2023-11-28 09:39:38 -0500 | |
commit | 000e8f4654cae9982e21e0a858366c4844139db6 (patch) | |
tree | 36001de27a149aecd7b5e67276026b6ac68dab12 /packages/integrations/node/test/headers.test.js | |
parent | 415fec54f8340a1ffcd6b926c1f5b1a0e0645e5a (diff) | |
download | astro-000e8f4654cae9982e21e0a858366c4844139db6.tar.gz astro-000e8f4654cae9982e21e0a858366c4844139db6.tar.zst astro-000e8f4654cae9982e21e0a858366c4844139db6.zip |
feat: implement overlay main screen redesign (#9118)
* feat: implement redesign
* fix: make it build
* feat: visual tweaks
* feat(overlay): update styling, integration endpoint
* feat: add fallback icons
* Clean up tests (#9183)
* Add `@astrojs/upgrade` package for automatic package upgrades (#8525)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* [ci] format
* fix: links with same path but different search params not prefetched (#9189)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* fix: discord icon
* chore: changeset
---------
Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Spencer Whitehead <35475068+SpencerWhitehead7@users.noreply.github.com>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'packages/integrations/node/test/headers.test.js')
-rw-r--r-- | packages/integrations/node/test/headers.test.js | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/packages/integrations/node/test/headers.test.js b/packages/integrations/node/test/headers.test.js new file mode 100644 index 000000000..17cfd3701 --- /dev/null +++ b/packages/integrations/node/test/headers.test.js @@ -0,0 +1,147 @@ +import nodejs from '../dist/index.js'; +import { loadFixture, createRequestAndResponse } from './test-utils.js'; +import { expect } from 'chai'; + +describe('Node Adapter Headers', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/headers/', + output: 'server', + adapter: nodejs({ mode: 'middleware' }), + }); + await fixture.build(); + }); + + it('Endpoint Simple Headers', async () => { + await runTest('/endpoints/simple', { + 'content-type': 'text/plain;charset=utf-8', + 'x-hello': 'world', + }); + }); + + it('Endpoint Astro Single Cookie Header', async () => { + await runTest('/endpoints/astro-cookies-single', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': 'from1=astro1', + }); + }); + + it('Endpoint Astro Multi Cookie Header', async () => { + await runTest('/endpoints/astro-cookies-multi', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': ['from1=astro1', 'from2=astro2'], + }); + }); + + it('Endpoint Response Single Cookie Header', async () => { + await runTest('/endpoints/response-cookies-single', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': 'hello1=world1', + }); + }); + + it('Endpoint Response Multi Cookie Header', async () => { + await runTest('/endpoints/response-cookies-multi', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': ['hello1=world1', 'hello2=world2'], + }); + }); + + it('Endpoint Complex Headers Kitchen Sink', async () => { + await runTest('/endpoints/kitchen-sink', { + 'content-type': 'text/plain;charset=utf-8', + 'x-single': 'single', + 'x-triple': 'one, two, three', + 'set-cookie': ['hello1=world1', 'hello2=world2'], + }); + }); + + it('Endpoint Astro and Response Single Cookie Header', async () => { + await runTest('/endpoints/astro-response-cookie-single', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': ['from1=response1', 'from1=astro1'], + }); + }); + + it('Endpoint Astro and Response Multi Cookie Header', async () => { + await runTest('/endpoints/astro-response-cookie-multi', { + 'content-type': 'text/plain;charset=utf-8', + 'set-cookie': ['from1=response1', 'from2=response2', 'from3=astro1', 'from4=astro2'], + }); + }); + + it('Endpoint Response Empty Headers Object', async () => { + await runTest('/endpoints/response-empty-headers-object', { + 'content-type': 'text/plain;charset=UTF-8', + }); + }); + + it('Endpoint Response undefined Headers Object', async () => { + await runTest('/endpoints/response-undefined-headers-object', { + 'content-type': 'text/plain;charset=UTF-8', + }); + }); + + it('Component Astro Single Cookie Header', async () => { + await runTest('/astro/component-astro-cookies-single', { + 'content-type': 'text/html', + 'set-cookie': 'from1=astro1', + }); + }); + + it('Component Astro Multi Cookie Header', async () => { + await runTest('/astro/component-astro-cookies-multi', { + 'content-type': 'text/html', + 'set-cookie': ['from1=astro1', 'from2=astro2'], + }); + }); + + it('Component Response Single Cookie Header', async () => { + await runTest('/astro/component-response-cookies-single', { + 'content-type': 'text/html', + 'set-cookie': 'from1=value1', + }); + }); + + it('Component Response Multi Cookie Header', async () => { + await runTest('/astro/component-response-cookies-multi', { + 'content-type': 'text/html', + 'set-cookie': ['from1=value1', 'from2=value2'], + }); + }); + + it('Component Astro and Response Single Cookie Header', async () => { + await runTest('/astro/component-astro-response-cookie-single', { + 'content-type': 'text/html', + 'set-cookie': ['from1=response1', 'from1=astro1'], + }); + }); + + it('Component Astro and Response Multi Cookie Header', async () => { + await runTest('/astro/component-astro-response-cookie-multi', { + 'content-type': 'text/html', + 'set-cookie': ['from1=response1', 'from2=response2', 'from3=astro1', 'from4=astro2'], + }); + }); +}); + +async function runTest(url, expectedHeaders) { + const { handler } = await import('./fixtures/headers/dist/server/entry.mjs'); + + let { req, res, done } = createRequestAndResponse({ + method: 'GET', + url, + }); + + handler(req, res); + + req.send(); + + await done; + const headers = res.getHeaders(); + + expect(headers).to.deep.equal(expectedHeaders); +} |