MCPcopy Index your code
hub / github.com/fb55/htmlparser2 / testStream

Function testStream

src/WritableStream.spec.ts:52–79  ·  view source on GitHub ↗
(
    file: string,
    options?: ParserOptions,
)

Source from the content-addressed store, hash-verified

50}
51
52async function testStream(
53 file: string,
54 options?: ParserOptions,
55): Promise<void> {
56 const filePath = new URL(`__fixtures__/Documents/${file}`, import.meta.url);
57
58 const [streamHandler, eventsPromise] = getPromiseEventCollector();
59
60 const fsStream = createReadStream(filePath).pipe(
61 new WritableStream(streamHandler, options),
62 );
63
64 await finished(fsStream);
65
66 const events = await eventsPromise;
67
68 expect(events).toMatchSnapshot();
69
70 const [singlePassHandler, singlePassPromise] = getPromiseEventCollector();
71
72 const singlePassStream = new WritableStream(singlePassHandler, options).end(
73 await fs.readFile(filePath),
74 );
75
76 await finished(singlePassStream);
77
78 expect(await singlePassPromise).toStrictEqual(events);
79}

Callers 1

Calls 2

getPromiseEventCollectorFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…