From 990eb9e483727f2a2716af5b849cf8600d307eef Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Wed, 11 Apr 2018 11:02:35 +0530 Subject: [PATCH] [tests] Updated Fuse specs --- spec/Fuse-spec.js | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ spec/SelectSpec.js | 51 -------------------------------- 2 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 spec/Fuse-spec.js delete mode 100644 spec/SelectSpec.js diff --git a/spec/Fuse-spec.js b/spec/Fuse-spec.js new file mode 100644 index 0000000..0ea9431 --- /dev/null +++ b/spec/Fuse-spec.js @@ -0,0 +1,87 @@ +'use strict'; + +const Fuse = require('../index'); + +/* global describe it expect */ +describe("Fuse", () => { + + it("Should return 'Is 10'", () => { + const a = 10; + + const result = new Fuse(a) + .on(x => x > 10, () => 'Greater than 10') + .on(x => x < 10, () => 'Lesser than 10') + .on(x => x === 10, () => 'Is 10'); + + expect(result.resolve()).toBe('Is 10'); + }); + + it("Should return 'Less than 10'", () => { + const a = 1; + + const result = new Fuse(a) + .on(x => x > 10, () => 'Greater than 10') + .on(x => x < 10, () => 'Lesser than 10') + .on(x => x === 10, () => `Is 10`); + + expect(result.resolve()).toBe('Lesser than 10'); + }); + + it("Should return 'Greater than 10'", () => { + const a = 100; + + const result = new Fuse(a) + .on(x => x > 10, () => 'Greater than 10') + .on(x => x < 10, () => 'Lesser than 10') + .on(x => x === 10, () => `Is 10`); + + expect(result.resolve()).toBe('Greater than 10'); + }); + + it(`Should return '"a" was an array'`, () => { + const a = [ 1, 2 ]; + + const result = new Fuse(a) + .on(x => Array.isArray(x), () => `"a" was an array`); + + expect(result.resolve()).toBe(`"a" was an array`); + }); + + it(`Should return 'null'`, () => { + const a = 1; + + const result = new Fuse(a) + .on(Array.isArray, () => `"a" was an array`); + + expect(result.resolve()).toBe(null); + }); + + it(`Should return 'null'`, () => { + const a = 'UnexpectedString'; + + const result = new Fuse(a) + .on(x => x > 10, () => 'Greater than 10') + .on(x => x < 10, () => 'Lesser than 10') + .on(x => x === 10, () => `Is 10`); + + expect(result.resolve()).toBe(null); + }); + + it(`Should return true`, () => { + const a = 'ExpectedString'; + + const result = new Fuse(a) + .is('ExpectedString', () => true); + + expect(result.resolve()).toBe(true); + }); + + it(`Should return true`, () => { + const a = 'ExpectedString'; + + const result = new Fuse(a) + .not('UnexpectedString', () => true); + + expect(result.resolve()).toBe(true); + }); +}); diff --git a/spec/SelectSpec.js b/spec/SelectSpec.js deleted file mode 100644 index 04e6e8f..0000000 --- a/spec/SelectSpec.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -const Select = require('../Select'); - -/* global describe it expect */ -describe("Select", () => { - - it("Should return 'Is 10'", () => { - const a = 10; - - 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'); - - expect(result.resolve()).toBe('Is 10'); - }); - - it("Should return 'Less than 10'", () => { - const a = 1; - - 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`); - - expect(result.resolve()).toBe('Lesser than 10'); - }); - - it("Should return 'Greater than 10'", () => { - const a = 100; - - 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`); - - expect(result.resolve()).toBe('Greater than 10'); - }); - - it("Should return 'null'", () => { - const a = '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`); - - expect(result.resolve()).toBe(null); - }); -});