From 298a21a76880651368ac286a90ec1d79e4e63c70 Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Tue, 10 Apr 2018 01:08:09 +0530 Subject: [PATCH] [tests] Updated tests to reflect no-satisfying-test scenario --- spec/SelectArraySpec.js | 24 ++++++++++++++---------- spec/SelectSpec.js | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/spec/SelectArraySpec.js b/spec/SelectArraySpec.js index 8aad699..1612169 100644 --- a/spec/SelectArraySpec.js +++ b/spec/SelectArraySpec.js @@ -5,16 +5,20 @@ 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 ]; + it("Should return array" + + "[ 'Is 10', 'Greater than 10', 'Lesser than 10', null ]", + () => { + const a = [ 10, 20, 0, 'UnexpectedString' ]; - 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`); + 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' ]); - }); + expect(result.resolve()) + .toEqual([ 'Is 10', + 'Greater than 10', + 'Lesser than 10', + null ]); + }); }); diff --git a/spec/SelectSpec.js b/spec/SelectSpec.js index 5f8966e..b609761 100644 --- a/spec/SelectSpec.js +++ b/spec/SelectSpec.js @@ -11,9 +11,9 @@ describe("Select", () => { 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`); + .for(x => x === 10, () => 'Is 10'); - expect(result.resolve()).toBe(`Is 10`); + expect(result.resolve()).toBe('Is 10'); }); it("Should return 'Less than 10'", () => { @@ -37,4 +37,15 @@ describe("Select", () => { expect(result.resolve()).toBe('Greater than 10'); }); + + it("Should return 'null'", () => { + const a = 'UnexpectedString'; + + 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()).toBe(null); + }); });