Home / File/ cookies.test.js — astro Source File

cookies.test.js — astro Source File

Architecture documentation for cookies.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  865ad043_56bb_3f6a_3543_c95b75584a97["cookies.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  865ad043_56bb_3f6a_3543_c95b75584a97 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  865ad043_56bb_3f6a_3543_c95b75584a97 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  865ad043_56bb_3f6a_3543_c95b75584a97 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  865ad043_56bb_3f6a_3543_c95b75584a97 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 865ad043_56bb_3f6a_3543_c95b75584a97 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { loadFixture } from '../../../../astro/test/test-utils.js';

describe(
	'Cookies',
	() => {
		let fixture;

		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/v1/functions/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 partitioned cookie', async () => {
			const entryURL = new URL(
				'./fixtures/cookies/.netlify/v1/functions/ssr/ssr.mjs',
				import.meta.url,
			);
			const { default: handler } = await import(entryURL);
			const resp = await handler(new Request('http://example.com/partitioned'), {});
			assert.equal(resp.status, 200);
			const cookie = resp.headers.getSetCookie()[0];
			assert.ok(cookie.includes('Partitioned'), 'Cookie should include Partitioned attribute');
		});

		it('renders dynamic 404 page', async () => {
			const entryURL = new URL(
				'./fixtures/cookies/.netlify/v1/functions/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,
	},
);

Domain

Dependencies

Frequently Asked Questions

What does cookies.test.js do?
cookies.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does cookies.test.js depend on?
cookies.test.js imports 4 module(s): loadFixture, node:test, strict, test-utils.js.
Where is cookies.test.js in the architecture?
cookies.test.js is located at packages/integrations/netlify/test/functions/cookies.test.js (domain: CoreAstro, directory: packages/integrations/netlify/test/functions).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free