From 942e67c00b8ebdf6671fc8bb2e6c78c3ad8b3ff8 Mon Sep 17 00:00:00 2001 From: Yusuke Sakurai Date: Thu, 27 Feb 2020 00:48:35 +0900 Subject: refactor(std/http): move io functions to http/io.ts (#4126) --- std/http/mock.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 std/http/mock.ts (limited to 'std/http/mock.ts') diff --git a/std/http/mock.ts b/std/http/mock.ts new file mode 100644 index 000000000..3a4eeed82 --- /dev/null +++ b/std/http/mock.ts @@ -0,0 +1,26 @@ +/** Create dummy Deno.Conn object with given base properties */ +export function mockConn(base: Partial = {}): Deno.Conn { + return { + localAddr: { + transport: "tcp", + hostname: "", + port: 0 + }, + remoteAddr: { + transport: "tcp", + hostname: "", + port: 0 + }, + rid: -1, + closeRead: (): void => {}, + closeWrite: (): void => {}, + read: async (): Promise => { + return 0; + }, + write: async (): Promise => { + return -1; + }, + close: (): void => {}, + ...base + }; +} -- cgit v1.2.3