Add test coverage.

This commit is contained in:
David Braun 2017-12-06 14:30:53 -05:00
parent 9da406e58f
commit 4315a28f0c
4 changed files with 37 additions and 7 deletions

View file

@ -136,6 +136,7 @@ describe(`Channel`, function() {
const channel = Channel();
Channel.select([channel.push(`cancelled`)]).cancel();
const closed = Channel.of();
assert.equal(
await Channel.select([channel.shift(), closed.shift()]),
closed
@ -211,6 +212,18 @@ describe(`Channel object`, function() {
channel.close();
assert.strictEqual(await channel.shift(), undefined);
});
it(`Don't set 'lastValue' to 'undefined' when closing a channel with a cancelled shift.`, async function() {
const channel = Channel();
// Set lastValue to 0.
channel.push(0);
await channel.shift();
channel.shift().cancel();
channel.close();
assert.strictEqual(channel.value(), 0);
});
});
it(`concat`, async function() {
@ -386,6 +399,15 @@ describe(`Channel object`, function() {
[1, 2, 3]
);
});
it(`start after end of channel`, async function() {
assert.deepEqual(
await Channel.of(0, 1, 2)
.slice(10)
.values(),
[]
);
});
});
it(`some`, async function() {