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
|
import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import * as cheerio from 'cheerio';
import { astroCli } from './_test-utils.js';
const root = new URL('./fixtures/astro-dev-platform/', import.meta.url);
describe('AstroDevPlatform', () => {
let cli;
before(async () => {
cli = astroCli(fileURLToPath(root), 'dev', '--host', '127.0.0.1');
await new Promise((resolve) => {
cli.stdout.on('data', (data) => {
if (data.includes('http://127.0.0.1:4321/')) {
resolve();
}
});
});
});
after((_done) => {
cli.kill();
});
it('exists', async () => {
const res = await fetch('http://127.0.0.1:4321/');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasRuntime').text().includes('true'), true);
});
it('adds cf object', async () => {
const res = await fetch('http://127.0.0.1:4321/');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasCF').text(), 'true');
});
it('adds cache mocking', async () => {
const res = await fetch('http://127.0.0.1:4321/caches');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasCACHE').text(), 'true');
});
it('adds D1 mocking', async () => {
const res = await fetch('http://127.0.0.1:4321/d1');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasDB').text(), 'true');
assert.equal($('#hasPRODDB').text(), 'true');
assert.equal($('#hasACCESS').text(), 'true');
});
it('adds R2 mocking', async () => {
const res = await fetch('http://127.0.0.1:4321/r2');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasBUCKET').text(), 'true');
assert.equal($('#hasPRODBUCKET').text(), 'true');
assert.equal($('#hasACCESS').text(), 'true');
});
it('adds KV mocking', async () => {
const res = await fetch('http://127.0.0.1:4321/kv');
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#hasKV').text(), 'true');
assert.equal($('#hasPRODKV').text(), 'true');
assert.equal($('#hasACCESS').text(), 'true');
});
});
|