Skip to content

Commit

Permalink
test: add decorator utils test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentuso committed May 28, 2019
1 parent 060f214 commit e892763
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/decorators/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'jest';
import 'reflect-metadata';
import { resolveType } from '../utils';
import { GraphQLString } from 'graphql';
import Field from '../Field';
import { Wrapper } from '../../wrappers/Wrapper';

class Foo {
@Field()
a: string = 'a';

@Field()
b = 'b';
}

describe('utils', () => {
describe('resolveType', () => {
it('should resolve type through reflection if not supplied', () => {
const type = resolveType(undefined, Foo.prototype, 'a');
expect((type as Wrapper<any, any>).graphQLType).toEqual(GraphQLString);
});

it('should throw error if type not available', () => {
expect(() => resolveType(undefined, Foo.prototype, 'b')).toThrow();
});
});
});

0 comments on commit e892763

Please sign in to comment.