mirror of https://github.com/codefeathers/fuse
Muthu Kumar
7 years ago
2 changed files with 44 additions and 25 deletions
@ -0,0 +1,44 @@ |
|||||
|
'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 |
||||
|
]); |
||||
|
}); |
||||
|
}); |
@ -1,25 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
const Select = require('../Select'); |
|
||||
|
|
||||
/* global describe it expect */ |
|
||||
describe("Select", () => { |
|
||||
|
|
||||
it("Should return array" + |
|
||||
"[ 'Is 10', 'Greater than 10', 'Lesser than 10', null ]", |
|
||||
() => { |
|
||||
const a = [ 10, 20, 0, 'UnexpectedString' ]; |
|
||||
|
|
||||
const result = new Select(a) |
|
||||
.if(x => x > 10, () => 'Greater than 10') |
|
||||
.if(x => x < 10, () => 'Lesser than 10') |
|
||||
.if(x => x === 10, () => `Is 10`); |
|
||||
console.log(result.resolve()); |
|
||||
expect(result.resolve()).toEqual([ |
|
||||
'Is 10', |
|
||||
'Greater than 10', |
|
||||
'Lesser than 10', |
|
||||
null |
|
||||
]); |
|
||||
}); |
|
||||
}); |
|
Loading…
Reference in new issue