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

27 lines
594 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 => {},
2020-03-20 09:38:34 -04:00
read: (): Promise<number | Deno.EOF> => {
return Promise.resolve(0);
},
2020-03-20 09:38:34 -04:00
write: (): Promise<number> => {
return Promise.resolve(-1);
},
close: (): void => {},
...base
};
}