strom/tests/last.spec.ts
2019-12-02 16:05:27 -05:00

17 lines
506 B
TypeScript

import { Readable } from "stream";
import test from "ava";
import { expect } from "chai";
import mhysa from "../src";
const { last } = mhysa();
test("last() resolves to the last chunk streamed by the given readable stream", async t => {
const source = new Readable({ objectMode: true });
const lastPromise = last(source);
source.push("ab");
source.push("cd");
source.push("ef");
source.push(null);
const lastChunk = await lastPromise;
expect(lastChunk).to.equal("ef");
});