mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 14:11:14 +00:00
fix(std/examples): add tests for examples (#4094)
This commit is contained in:
parent
162d66d23f
commit
fe9ac35a65
16 changed files with 258 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert, assertEquals } from "../../testing/asserts.ts";
|
||||
import { TextProtoReader } from "../../textproto/mod.ts";
|
||||
import { BufReader } from "../../io/bufio.ts";
|
||||
|
@ -22,10 +23,12 @@ async function startServer(): Promise<void> {
|
|||
|
||||
const { test } = Deno;
|
||||
|
||||
await startServer();
|
||||
test("beforeAll", async () => {
|
||||
await startServer();
|
||||
});
|
||||
|
||||
test("GET / should serve html", async () => {
|
||||
const resp = await fetch("http://0.0.0.0:8080/");
|
||||
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();
|
||||
|
@ -34,7 +37,7 @@ test("GET / should serve html", async () => {
|
|||
|
||||
let ws: WebSocket | undefined;
|
||||
test("GET /ws should upgrade conn to ws", async () => {
|
||||
ws = await connectWebSocket("http://0.0.0.0:8080/ws");
|
||||
ws = await connectWebSocket("http://127.0.0.1:8080/ws");
|
||||
const it = ws.receive();
|
||||
assertEquals((await it.next()).value, "Connected: [1]");
|
||||
ws.send("Hello");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue