mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
27 lines
638 B
TypeScript
27 lines
638 B
TypeScript
// 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> => {
|
|
return Promise.resolve(0);
|
|
},
|
|
write: (): Promise<number> => {
|
|
return Promise.resolve(-1);
|
|
},
|
|
close: (): void => {},
|
|
...base,
|
|
};
|
|
}
|