Skip to content

Commit d49d5b5

Browse files
committed
Updating tests and examples
1 parent 0723ac0 commit d49d5b5

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

runtest.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
npm run test
1+
yarn run test
22

33
if [ "$?" -gt 0 ]; then
44
exit 1
55
fi
66

77
cd examples/hello-world/
88

9-
npm install
10-
npm start
9+
yarn install --production
10+
yarn start
1111

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

1717
cd examples/simple-crud
1818

19-
npm install
20-
npm run print
19+
yarn install --production
20+
yarn run print
2121

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

src/specs/functional.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'reflect-metadata';
2+
3+
import * as D from '../decorator';
4+
import * as graphql from 'graphql';
5+
6+
import { schemaFactory } from '../type-factory';
7+
8+
const assert = require('assert');
9+
10+
describe('Functional', function () {
11+
describe('Schema', function () {
12+
13+
it('resolves @D.Field', async function() {
14+
15+
@D.ObjectType()
16+
class QueryType {
17+
@D.Field() greeting(): string {
18+
return 'Hello, world!';
19+
}
20+
}
21+
22+
@D.Schema()
23+
class SchemaType {
24+
@D.Query() query: QueryType;
25+
}
26+
27+
const schema = schemaFactory(SchemaType);
28+
const result = await graphql.graphql(schema, `query { greeting } `);
29+
assert(result.data.greeting === 'Hello, world!');
30+
});
31+
32+
});
33+
});

src/type-factory/enum-value.type-factory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import 'reflect-metadata';
2+
3+
import { SchemaFactoryError, SchemaFactoryErrorType } from './schema.type-factory';
4+
15
import { EnumValueMetadata } from '../metadata';
2-
import { SchemaFactoryError , SchemaFactoryErrorType } from './schema.type-factory';
36

47
export function enumValueTypeFactory(target: Function, metadata: EnumValueMetadata): any {
58
let description = metadata.description;

src/type-factory/field.type-factory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'reflect-metadata';
2+
13
import * as graphql from 'graphql';
24

35
import {

src/type-factory/schema.type-factory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'reflect-metadata';
2+
13
import * as graphql from 'graphql';
24

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

0 commit comments

Comments
 (0)