2019-08-15 21:06:54 +00:00
|
|
|
import { Readable } from "stream";
|
|
|
|
import test from "ava";
|
|
|
|
import { expect } from "chai";
|
2019-08-16 13:02:54 +00:00
|
|
|
import { last } from "../src";
|
2019-08-15 21:06:54 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
});
|