1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00
denoland-deno/std/http/_mock_conn.ts

28 lines
638 B
TypeScript
Raw Normal View History

2020-09-21 08:26:41 -04:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/** Create dummy Deno.Conn object with given base properties */
export function mockConn(base: Partial<Deno.Conn> = {}): Deno.Conn {
return {
localAddr: {
transport: "tcp",
hostname: "",
port: 0,
},
remoteAddr: {
transport: "tcp",
hostname: "",
port: 0,
},
rid: -1,
closeWrite: (): void => {},
read: (): Promise<number | null> => {
2020-03-20 09:38:34 -04:00
return Promise.resolve(0);
},
write: (): Promise<number> => {
return Promise.resolve(-1);
},
close: (): void => {},
...base,
};
}