redioactive
Version:
Reactive streams for chaining overlapping promises.
32 lines (31 loc) • 1.59 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const redio_1 = __importDefault(require("../redio"));
describe('Dropping values from the start of a stream', () => {
test('By default, drops a single value from a stream', async () => {
await expect((0, redio_1.default)([1, 2, 3, 4]).drop().toArray()).resolves.toEqual([2, 3, 4]);
});
test('Drops a single value from a stream', async () => {
await expect((0, redio_1.default)([1, 2, 3, 4]).drop(1).toArray()).resolves.toEqual([2, 3, 4]);
});
test('Drops two values from a stream', async () => {
await expect((0, redio_1.default)([1, 2, 3, 4]).drop(2).toArray()).resolves.toEqual([3, 4]);
});
test('Drops two values by a promise from a stream', async () => {
await expect((0, redio_1.default)([1, 2, 3, 4]).drop(Promise.resolve(2)).toArray()).resolves.toEqual([3, 4]);
});
test('Copes with an empty stream', async () => {
await expect((0, redio_1.default)([]).drop().toArray()).resolves.toEqual([]);
});
test('Copes with an empty stream and large number', async () => {
await expect((0, redio_1.default)([]).drop(42).toArray()).resolves.toEqual([]);
});
test('Can be chained', async () => {
await expect((0, redio_1.default)([1, 2, 3, 4]).drop(1).drop(Promise.resolve(2)).toArray()).resolves.toEqual([
4
]);
});
});