mirror of
https://github.com/denoland/deno.git
synced 2024-10-30 09:08:00 -04:00
27 lines
572 B
TypeScript
27 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
|
||
|
};
|
||
|
}
|