forked from withastro/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-mode.test.js
100 lines (88 loc) · 2.71 KB
/
config-mode.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
describe('AstroConfig - config.output', () => {
describe(`output: 'server'`, () => {
describe('deploy config provided', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
// This is just a random fixture to test, doesn't matter.
root: './fixtures/astro-basic/',
adapter: testAdapter(),
output: 'server',
});
await fixture.build();
});
it('Builds an SSR-able app', async () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/');
const response = await app.render(request);
assert.equal(response.status, 200);
assert.equal(response.headers.get('content-type'), 'text/html');
const html = await response.text();
assert.equal(html.length > 0, true);
});
});
describe('deploy config omitted', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
// This is just a random fixture to test, doesn't matter.
root: './fixtures/astro-basic/',
output: 'server',
});
});
it('Throws during the build', async () => {
let built = false;
try {
await fixture.build();
built = true;
} catch (err) {
assert.equal(err instanceof Error, true);
assert.match(err.message, /without an adapter/);
}
assert.equal(built, false, 'Should not have built');
});
});
});
describe(`output: 'static'`, () => {
describe('Output config omitted', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
// This is just a random fixture to test, doesn't matter.
root: './fixtures/astro-basic/',
output: 'static',
});
await fixture.build();
});
it('Builds to static HTML', async () => {
let html;
try {
html = await fixture.readFile('/index.html');
} catch {
assert.equal(false, true, 'Couldnt find the file, which mean it did not build.');
}
assert.equal(html.length > 0, true);
});
});
describe.skip('deploy config provided - TODO, we need adapters to support static mode first', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
// This is just a random fixture to test, doesn't matter.
root: './fixtures/astro-basic/',
adapter: testAdapter(),
output: 'server',
});
await fixture.build();
});
});
});
});