UNPKG

redioactive

Version:

Reactive streams for chaining overlapping promises.

30 lines (29 loc) 1.36 kB
"use strict"; 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('Testing flat mapping of a stream to streams', () => { test('Convert some uppercase strings to lowercase', async () => { await expect((0, redio_1.default)(['ONE', 'Two', 'ThReE']) .flatMap((x) => (0, redio_1.default)([x.toLowerCase()])) .toArray()).resolves.toEqual(['one', 'two', 'three']); }); test('Copes with an empty streem', async () => { await expect((0, redio_1.default)([]) .flatMap((x) => (0, redio_1.default)([+x])) .toArray()).resolves.toEqual([]); }); test('Empty out a stream', async () => { await expect((0, redio_1.default)([1, 2, 3]) // eslint-disable-next-line @typescript-eslint/no-unused-vars .flatMap((_x) => (0, redio_1.default)([])) .toArray()).resolves.toEqual([]); }); test('Double up a stream', async () => { await expect((0, redio_1.default)([1, 2, 3]) .flatMap((x) => (0, redio_1.default)([x, x])) .toArray()).resolves.toEqual([1, 1, 2, 2, 3, 3]); }); });