From 6471d4cfabf27c0f5e7b340568aa88712d270541 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 15 Mar 2020 12:03:25 +0000 Subject: refactor(std): Uncomment disabled tests, use skip option (#4378) --- std/examples/chat/server_test.ts | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'std/examples/chat/server_test.ts') 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 { 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(); - }); -} + } +}); -- cgit v1.2.3