-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
astro-dev-headers.test.js
40 lines (35 loc) · 1.02 KB
/
astro-dev-headers.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { loadFixture } from './test-utils.js';
describe('Astro dev headers', () => {
let fixture;
let devServer;
const headers = {
'x-astro': 'test',
};
before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-dev-headers/',
server: {
headers,
},
});
await fixture.build();
devServer = await fixture.startDevServer();
});
after(async () => {
await devServer.stop();
});
describe('dev', () => {
it('returns custom headers for valid URLs', async () => {
const result = await fixture.fetch('/');
assert.equal(result.status, 200);
assert.equal(Object.fromEntries(result.headers)['x-astro'], headers['x-astro']);
});
it('returns custom headers in the default 404 response', async () => {
const result = await fixture.fetch('/bad-url');
assert.equal(result.status, 404);
assert.equal(Object.fromEntries(result.headers).hasOwnProperty('x-astro'), true);
});
});
});