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
|
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
import { astroCli } from './_test-utils.js';
const root = new URL('./fixtures/dev-runtime/', import.meta.url);
describe('Runtime Astro Dev', () => {
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();
setTimeout(() => {
console.log('CLEANED');
done();
}, 1000);
});
it('exists', async () => {
let res = await fetch(`http://127.0.0.1:4321/`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasRuntime').text()).to.contain('true');
});
it('adds cf object', async () => {
let res = await fetch(`http://127.0.0.1:4321/`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasCF').text()).to.equal('true');
});
it('adds cache mocking', async () => {
let res = await fetch(`http://127.0.0.1:4321/caches`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasCACHE').text()).to.equal('true');
});
it('adds D1 mocking', async () => {
let res = await fetch(`http://127.0.0.1:4321/d1`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasDB').text()).to.equal('true');
expect($('#hasPRODDB').text()).to.equal('true');
expect($('#hasACCESS').text()).to.equal('true');
});
it('adds R2 mocking', async () => {
let res = await fetch(`http://127.0.0.1:4321/r2`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasBUCKET').text()).to.equal('true');
expect($('#hasPRODBUCKET').text()).to.equal('true');
expect($('#hasACCESS').text()).to.equal('true');
});
it('adds KV mocking', async () => {
let res = await fetch(`http://127.0.0.1:4321/kv`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasKV').text()).to.equal('true');
expect($('#hasPRODKV').text()).to.equal('true');
expect($('#hasACCESS').text()).to.equal('true');
});
it('adds DO mocking', async () => {
let res = await fetch(`http://127.0.0.1:4321/do`);
let html = await res.text();
let $ = cheerio.load(html);
expect($('#hasDO').text()).to.equal('true');
});
});
|