Skip to content

Commit

Permalink
Updating tests and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
felipesabino committed Nov 3, 2017
1 parent 0723ac0 commit d49d5b5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
10 changes: 5 additions & 5 deletions runtest.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
npm run test
yarn run test

if [ "$?" -gt 0 ]; then
exit 1
fi

cd examples/hello-world/

npm install
npm start
yarn install --production
yarn start

if [ "$?" -gt 0 ]; then
exit 1
Expand All @@ -16,8 +16,8 @@ cd ../../

cd examples/simple-crud

npm install
npm run print
yarn install --production
yarn run print

if [ "$?" -gt 0 ]; then
exit 1
Expand Down
33 changes: 33 additions & 0 deletions src/specs/functional.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'reflect-metadata';

import * as D from '../decorator';
import * as graphql from 'graphql';

import { schemaFactory } from '../type-factory';

const assert = require('assert');

describe('Functional', function () {
describe('Schema', function () {

it('resolves @D.Field', async function() {

@D.ObjectType()
class QueryType {
@D.Field() greeting(): string {
return 'Hello, world!';
}
}

@D.Schema()
class SchemaType {
@D.Query() query: QueryType;
}

const schema = schemaFactory(SchemaType);
const result = await graphql.graphql(schema, `query { greeting } `);
assert(result.data.greeting === 'Hello, world!');
});

});
});
5 changes: 4 additions & 1 deletion src/type-factory/enum-value.type-factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'reflect-metadata';

import { SchemaFactoryError, SchemaFactoryErrorType } from './schema.type-factory';

import { EnumValueMetadata } from '../metadata';
import { SchemaFactoryError , SchemaFactoryErrorType } from './schema.type-factory';

export function enumValueTypeFactory(target: Function, metadata: EnumValueMetadata): any {
let description = metadata.description;
Expand Down
2 changes: 2 additions & 0 deletions src/type-factory/field.type-factory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'reflect-metadata';

import * as graphql from 'graphql';

import {
Expand Down
2 changes: 2 additions & 0 deletions src/type-factory/schema.type-factory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'reflect-metadata';

import * as graphql from 'graphql';

import { EntryType, EntryTypeMetadata, FieldMetadata } from '../metadata';
Expand Down

0 comments on commit d49d5b5

Please sign in to comment.