1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/std/http/mock.ts

27 lines
572 B
TypeScript
Raw Normal View History

/** 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
};
}