(
file: string,
options?: ParserOptions,
)
| 50 | } |
| 51 | |
| 52 | async 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 | } |
no test coverage detected
searching dependent graphs…