From a22ae768cac09c079223e497d5dca19136f229bf Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Wed, 11 Apr 2018 11:02:48 +0530 Subject: [PATCH] [tests] Updated FuseIterable specs --- spec/FuseIterable-spec.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ spec/SelectArraySpec.js | 25 ------------------------- 2 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 spec/FuseIterable-spec.js delete mode 100644 spec/SelectArraySpec.js diff --git a/spec/FuseIterable-spec.js b/spec/FuseIterable-spec.js new file mode 100644 index 0000000..fc85c2e --- /dev/null +++ b/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 + ]); + }); +}); diff --git a/spec/SelectArraySpec.js b/spec/SelectArraySpec.js deleted file mode 100644 index 659e527..0000000 --- a/spec/SelectArraySpec.js +++ /dev/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 - ]); - }); -});