From 83fe99d22bc2c2c829b3029a8d6f93503e77c7cf Mon Sep 17 00:00:00 2001 From: EnRoute Date: Mon, 14 Aug 2017 07:42:22 +0300 Subject: [PATCH] test(utils/get-type): Add two testcases for utils/get-type function. --- src/utils/get-type.test.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/utils/get-type.test.js b/src/utils/get-type.test.js index 181da20..0ce677e 100644 --- a/src/utils/get-type.test.js +++ b/src/utils/get-type.test.js @@ -11,7 +11,15 @@ describe('to map converter', () => { expect(type).to.be.instanceof(Types.ConfigFieldBaseType); }); - it('get type by name in "config.type" object', () => { + it('get type when in "config.type" instanceof BaseType', () => { + expect( + getType({ + type: new Types.StringType(), + }), + ).to.be.instanceof(Types.ConfigFieldBaseType); + }); + + it('get type by name from "config.type" object', () => { const type = getType({ type: { name: 'number', @@ -24,11 +32,19 @@ describe('to map converter', () => { expect(type.applyValidators(2)).to.be.equal(false); }); - it('throw exeption on empty argument', () => { + it('throw exception on get type by name from "config.type" object', () => { + expect(() => getType({ + type: { + name: 'unknownType', + }, + })).to.be.throw('Unknown type'); + }); + + it('throw exception on empty argument', () => { expect(() => getType()).to.throw('Type of field must be string, object or object extend from ConfigFieldBaseType'); }); - it('throw exeption on unknown time', () => { + it('throw exception on unknown type', () => { expect(() => getType({ type: 'unknown' })).to.throw('Unknown type'); }); });