2020-09-21 08:26:41 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2020-02-26 10:48:35 -05:00
|
|
|
/** Create dummy Deno.Conn object with given base properties */
|
|
|
|
export function mockConn(base: Partial<Deno.Conn> = {}): Deno.Conn {
|
|
|
|
return {
|
|
|
|
localAddr: {
|
|
|
|
transport: "tcp",
|
|
|
|
hostname: "",
|
2020-03-28 13:03:49 -04:00
|
|
|
port: 0,
|
2020-02-26 10:48:35 -05:00
|
|
|
},
|
|
|
|
remoteAddr: {
|
|
|
|
transport: "tcp",
|
|
|
|
hostname: "",
|
2020-03-28 13:03:49 -04:00
|
|
|
port: 0,
|
2020-02-26 10:48:35 -05:00
|
|
|
},
|
|
|
|
rid: -1,
|
|
|
|
closeWrite: (): void => {},
|
2020-04-28 12:40:43 -04:00
|
|
|
read: (): Promise<number | null> => {
|
2020-03-20 09:38:34 -04:00
|
|
|
return Promise.resolve(0);
|
2020-02-26 10:48:35 -05:00
|
|
|
},
|
2020-04-02 15:20:17 -04:00
|
|
|
write: (): Promise<number> => {
|
|
|
|
return Promise.resolve(-1);
|
2020-02-26 10:48:35 -05:00
|
|
|
},
|
|
|
|
close: (): void => {},
|
2020-03-28 13:03:49 -04:00
|
|
|
...base,
|
2020-02-26 10:48:35 -05:00
|
|
|
};
|
|
|
|
}
|