mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
8cd38f0245
* fix(node): add user specified headers to preview server responses * docs: clarify comment * style: new line * test: remove test * chore: add changeset
38 lines
939 B
JavaScript
38 lines
939 B
JavaScript
import * as assert from 'node:assert/strict';
|
|
import { after, before, describe, it } from 'node:test';
|
|
import nodejs from '../dist/index.js';
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
describe('Astro preview headers', () => {
|
|
/** @type {import('./test-utils').Fixture} */
|
|
let fixture;
|
|
let devPreview;
|
|
const headers = {
|
|
astro: 'test',
|
|
};
|
|
|
|
before(async () => {
|
|
fixture = await loadFixture({
|
|
root: './fixtures/preview-headers/',
|
|
output: 'server',
|
|
adapter: nodejs({ mode: 'standalone' }),
|
|
server: {
|
|
headers
|
|
},
|
|
});
|
|
await fixture.build();
|
|
devPreview = await fixture.preview();
|
|
});
|
|
|
|
after(async () => {
|
|
await devPreview.stop();
|
|
});
|
|
|
|
describe('Preview Headers', () => {
|
|
it('returns custom headers for valid URLs', async () => {
|
|
const result = await fixture.fetch('/');
|
|
assert.equal(result.status, 200);
|
|
assert.equal(Object.fromEntries(result.headers).astro, headers.astro);
|
|
});
|
|
});
|
|
});
|