FunctionSelect: Select a function that passes a condition. A functional alternative to switch-case.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

20 lines
496 B

'use strict';
const Select = require('../Select');
/* global describe it expect */
describe("Select", () => {
it("Should return array [ 'Is 10', 'Greater than 10', 'Lesser than 10' ]",
() => {
const a = [ 10, 20, 0 ];
const result = new Select(a)
.for(x => x > 10, () => 'Greater than 10')
.for(x => x < 10, () => 'Lesser than 10')
.for(x => x === 10, () => `Is 10`);
expect(result.resolve())
.toEqual([ 'Is 10', 'Greater than 10', 'Lesser than 10' ]);
});
});