mirror of https://github.com/codefeathers/fuse
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.
45 lines
993 B
45 lines
993 B
7 years ago
|
'use strict';
|
||
|
|
||
|
const { FuseIterable } = require('../index');
|
||
|
|
||
|
/* global describe it expect */
|
||
|
describe("FuseIterable", () => {
|
||
|
|
||
|
it("Should return array " +
|
||
|
"[ 'Is 10', 'Greater than 10', 'Lesser than 10', null ]",
|
||
|
() => {
|
||
|
const a = [ 10, 20, 0, 'UnexpectedString' ];
|
||
|
|
||
|
const result = new FuseIterable(a)
|
||
|
.on(x => x > 10, () => 'Greater than 10')
|
||
|
.on(x => x < 10, () => 'Lesser than 10')
|
||
|
.on(x => x === 10, () => `Is 10`);
|
||
|
|
||
|
expect(result.resolve()).toEqual([
|
||
|
'Is 10',
|
||
|
'Greater than 10',
|
||
|
'Lesser than 10',
|
||
|
null
|
||
|
]);
|
||
|
});
|
||
|
|
||
|
it("Should return array " +
|
||
|
"[ 'Is 10', 'Greater than 10', 'Lesser than 10', null ]",
|
||
|
() => {
|
||
|
const a = [ 10, 20, 0, 'UnexpectedString' ];
|
||
|
|
||
|
const result = new FuseIterable(a)
|
||
|
.onField(
|
||
|
[ x => x > 10, () => 'Greater than 10' ],
|
||
|
[ x => x < 10, () => 'Lesser than 10' ],
|
||
|
[ x => x === 10, () => `Is 10` ]);
|
||
|
|
||
|
expect(result.resolve()).toEqual([
|
||
|
'Is 10',
|
||
|
'Greater than 10',
|
||
|
'Lesser than 10',
|
||
|
null
|
||
|
]);
|
||
|
});
|
||
|
});
|