summaryrefslogtreecommitdiff
path: root/std/examples/chat/server_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/examples/chat/server_test.ts')
-rw-r--r--std/examples/chat/server_test.ts40
1 files changed, 29 insertions, 11 deletions
diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts
index 3e2a62ee0..c63453a19 100644
--- a/std/examples/chat/server_test.ts
+++ b/std/examples/chat/server_test.ts
@@ -24,29 +24,47 @@ async function startServer(): Promise<void> {
const { test, build } = Deno;
// TODO: https://github.com/denoland/deno/issues/4108
-if (build.os !== "win") {
- test("beforeAll", async () => {
+const skip = build.os == "win";
+
+test({
+ skip,
+ name: "beforeAll",
+ async fn() {
await startServer();
- });
+ }
+});
- test("GET / should serve html", async () => {
+test({
+ skip,
+ name: "GET / should serve html",
+ async fn() {
const resp = await fetch("http://127.0.0.1:8080/");
assertEquals(resp.status, 200);
assertEquals(resp.headers.get("content-type"), "text/html");
const html = await resp.body.text();
assert(html.includes("ws chat example"), "body is ok");
- });
+ }
+});
+
+let ws: WebSocket | undefined;
- let ws: WebSocket | undefined;
- test("GET /ws should upgrade conn to ws", async () => {
+test({
+ skip,
+ name: "GET /ws should upgrade conn to ws",
+ async fn() {
ws = await connectWebSocket("http://127.0.0.1:8080/ws");
const it = ws.receive();
assertEquals((await it.next()).value, "Connected: [1]");
ws.send("Hello");
assertEquals((await it.next()).value, "[1]: Hello");
- });
- test("afterAll", () => {
+ }
+});
+
+test({
+ skip,
+ name: "afterAll",
+ fn() {
server?.close();
ws?.conn.close();
- });
-}
+ }
+});