MCPcopy
hub / github.com/inkeep/open-knowledge / FakeServer

Class FakeServer

packages/desktop/src/main/share-handoff.test.ts:161–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161class FakeServer implements HandoffHttpServer {
162 handler: (req: HandoffHttpRequest, res: HandoffHttpResponse) => void;
163 errorCb: ((err: NodeJS.ErrnoException) => void) | null = null;
164 closed = false;
165 listening = false;
166 constructor(handler: (req: HandoffHttpRequest, res: HandoffHttpResponse) => void) {
167 this.handler = handler;
168 }
169 listen(_port: number, _host: string, cb: () => void) {
170 this.listening = true;
171 cb();
172 }
173 on(_event: 'error', cb: (err: NodeJS.ErrnoException) => void) {
174 this.errorCb = cb;
175 }
176 address() {
177 return { port: 52431 };
178 }
179 close() {
180 this.closed = true;
181 }
182 request(url: string): FakeResponse {
183 const res = new FakeResponse();
184 this.handler({ url }, res);
185 return res;
186 }
187}
188
189function harness(over: Partial<FirstRunHandshakeDeps> = {}) {
190 const outcomes: HandoffOutcome[] = [];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected