@guj/rif-js
Version:
Simplify filter,map and such when their use should be conditionnal
19 lines (14 loc) • 521 B
JavaScript
const test = require("ava");
const Rif = require("../main/rif");
test('Rifs should map when allowed to', t => {
const rSut = Rif
.of([1,2,3])
.mapIf(true)(x=>x*x);
t.deepEqual(rSut, [1,4,9], `Since we allow the mapping, we expect the result to be mapped`);
});
test('Rifs should not map when unallowed to', t => {
const rSut = Rif
.of([1,2,3])
.mapIf(false)(x=>x*x);
t.deepEqual(rSut, [1,2,3], `Since we forbid the mapping, we expect the result to be left as is`);
});