Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate tests #61

Merged
merged 5 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ jobs:
- name: Lint
run: deno lint

- name: Test
run: deno test -A --no-check

- name: Check
run: deno check src/**.ts
12 changes: 12 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions src/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { assert, assertEquals } from "jsr:@std/assert";
import { delay } from "jsr:@std/async";

Deno.test({
name: "tasks",
async fn(test) {
await test.step({
name: "build",
async fn() {
const command = new Deno.Command("deno", {
args: ["task", "build"],
});
const { code } = await command.output();

assertEquals(code, 0);
},
});

await test.step({
name: "dev",
async fn() {
const command = new Deno.Command("deno", {
args: ["task", "dev"],
stdout: "null",
stderr: "null",
});

const process = command.spawn();

/**
* Represents a failing promise while we get a real one
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408
*/
const pending = new Response(null, { status: 408 });

let response = pending;
while (!response.ok) {
response = await fetch("http://localhost:4507/mononykus/")
.catch(() => pending);
await delay(12);
}

const html = await response.text();

assert(html.startsWith("<!DOCTYPE html>"));
assert(html.includes("<title>Mononykus – Deno + Svelte</title>"));

process.kill();

await process.output();
},
});
},
});
6 changes: 5 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export const watch = async (

await _rebuild();

Deno.serve({ port: 4507, signal }, create_handler({ base, out_dir }));
const { finished } = Deno.serve(
{ port: 4507, signal },
create_handler({ base, out_dir }),
);

const watcher = Deno.watchFs(site_dir);
signal.addEventListener("abort", () => {
Expand All @@ -183,6 +186,7 @@ export const watch = async (

console.log("\nShutting down gracefully, light as a feather…");
await esbuild.stop();
await finished;
};

if (import.meta.main) {
Expand Down
Loading