mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
26 lines
572 B
TypeScript
26 lines
572 B
TypeScript
/** 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,
|
|
closeRead: (): void => {},
|
|
closeWrite: (): void => {},
|
|
read: async (): Promise<number | Deno.EOF> => {
|
|
return 0;
|
|
},
|
|
write: async (): Promise<number> => {
|
|
return -1;
|
|
},
|
|
close: (): void => {},
|
|
...base
|
|
};
|
|
}
|