Skip to content

Commit

Permalink
test(utils/get-type): Add two testcases for utils/get-type function.
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerlessCloud committed Aug 14, 2017
1 parent 1ff1ac5 commit 83fe99d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/utils/get-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
});
});

0 comments on commit 83fe99d

Please sign in to comment.