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