MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fakeStreams

Function fakeStreams

__tests__/watcher.test.ts:1419–1431  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1417 // for good (#2487). These drive that event shape through a fake fs.watch.
1418 type FakeStream = { listener: (event: string, name: string | null) => void; closed: number };
1419 const fakeStreams = () => {
1420 const streams = new Map<string, FakeStream>();
1421 const opened: string[] = [];
1422 __setFsWatchForTests(((dir: fs.PathLike, _opts: unknown, listener: FakeStream['listener']) => {
1423 const stream: FakeStream = { listener, closed: 0 };
1424 streams.set(String(dir), stream);
1425 opened.push(String(dir));
1426 const w = new EventEmitter() as fs.FSWatcher;
1427 w.close = () => { stream.closed += 1; };
1428 return w;
1429 }) as unknown as typeof fs.watch);
1430 return { streams, opened };
1431 };
1432 const selfName = (dir: string) => (process.platform === 'win32' ? `\\\\?\\${dir}` : dir);
1433
1434 it('closes a linked folder\'s stream once its target is deleted, with one check per burst (#2487)', async () => {

Callers 1

watcher.test.tsFile · 0.85

Calls 3

__setFsWatchForTestsFunction · 0.90
pushMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected