Browse Source

[tests] Updated FuseIterable specs

develop
Muthu Kumar 7 years ago
parent
commit
a22ae768ca
  1. 44
      spec/FuseIterable-spec.js
  2. 25
      spec/SelectArraySpec.js

44
spec/FuseIterable-spec.js

@ -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
]);
});
});

25
spec/SelectArraySpec.js

@ -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…
Cancel
Save