2024-05-22 03:17:53 -05:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { after, before, describe, it } from 'node:test';
|
2024-04-02 15:07:18 -05:00
|
|
|
import { load as cheerioLoad } from 'cheerio';
|
|
|
|
import { loadFixture } from '../../astro/test/test-utils.js';
|
|
|
|
import { setupRemoteDbServer } from './test-utils.js';
|
|
|
|
|
|
|
|
describe('astro:db', () => {
|
|
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({
|
|
|
|
root: new URL('./fixtures/static-remote/', import.meta.url),
|
|
|
|
output: 'static',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('static build --remote', () => {
|
|
|
|
let remoteDbServer;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
remoteDbServer = await setupRemoteDbServer(fixture.config);
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
|
|
|
after(async () => {
|
|
|
|
await remoteDbServer?.stop();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Can render page', async () => {
|
|
|
|
const html = await fixture.readFile('/index.html');
|
|
|
|
const $ = cheerioLoad(html);
|
|
|
|
|
2024-05-22 03:17:53 -05:00
|
|
|
assert.equal($('li').length, 1);
|
2024-04-02 15:07:18 -05:00
|
|
|
});
|
2024-05-21 16:12:39 -05:00
|
|
|
|
|
|
|
it('Returns correct shape from db.run()', async () => {
|
|
|
|
const html = await fixture.readFile('/run/index.html');
|
|
|
|
const $ = cheerioLoad(html);
|
|
|
|
|
2024-05-22 06:03:40 -05:00
|
|
|
assert.match($('#row').text(), /1/);
|
2024-05-21 16:12:39 -05:00
|
|
|
});
|
2024-04-02 15:07:18 -05:00
|
|
|
});
|
|
|
|
});
|