@@ -7,24 +7,57 @@ import { parse, parseValue } from '../../language/parser';
7
7
import { print } from '../../language/printer' ;
8
8
import { visit } from '../../language/visitor' ;
9
9
10
+ import { GraphQLSchema } from '../../type/schema' ;
10
11
import { getNamedType , isCompositeType } from '../../type/definition' ;
11
12
12
13
import { buildSchema } from '../buildASTSchema' ;
13
14
import { TypeInfo , visitWithTypeInfo } from '../TypeInfo' ;
14
15
15
- import { testSchema } from '../../validation/__tests__/harness' ;
16
+ const testSchema = buildSchema ( `
17
+ interface Pet {
18
+ name: String
19
+ }
20
+
21
+ type Dog implements Pet {
22
+ name: String
23
+ }
24
+
25
+ type Cat implements Pet {
26
+ name: String
27
+ }
28
+
29
+ type Human {
30
+ name: String
31
+ pets: [Pet]
32
+ }
33
+
34
+ type Alien {
35
+ name(surname: Boolean): String
36
+ }
37
+
38
+ type QueryRoot {
39
+ human(id: ID): Human
40
+ alien: Alien
41
+ }
42
+
43
+ schema {
44
+ query: QueryRoot
45
+ }
46
+ ` ) ;
16
47
17
48
describe ( 'TypeInfo' , ( ) => {
49
+ const schema = new GraphQLSchema ( { } ) ;
50
+
18
51
it ( 'can be Object.toStringified' , ( ) => {
19
- const typeInfo = new TypeInfo ( testSchema ) ;
52
+ const typeInfo = new TypeInfo ( schema ) ;
20
53
21
54
expect ( Object . prototype . toString . call ( typeInfo ) ) . to . equal (
22
55
'[object TypeInfo]' ,
23
56
) ;
24
57
} ) ;
25
58
26
59
it ( 'allow all methods to be called before entering any node' , ( ) => {
27
- const typeInfo = new TypeInfo ( testSchema ) ;
60
+ const typeInfo = new TypeInfo ( schema ) ;
28
61
29
62
expect ( typeInfo . getType ( ) ) . to . equal ( undefined ) ;
30
63
expect ( typeInfo . getParentType ( ) ) . to . equal ( undefined ) ;
@@ -316,11 +349,16 @@ describe('visitWithTypeInfo', () => {
316
349
} ) ;
317
350
318
351
it ( 'supports traversals of input values' , ( ) => {
352
+ const schema = buildSchema ( `
353
+ input ComplexInput {
354
+ stringListField: [String]
355
+ }
356
+ ` ) ;
319
357
const ast = parseValue ( '{ stringListField: ["foo"] }' ) ;
320
- const complexInputType = testSchema . getType ( 'ComplexInput' ) ;
358
+ const complexInputType = schema . getType ( 'ComplexInput' ) ;
321
359
invariant ( complexInputType != null ) ;
322
360
323
- const typeInfo = new TypeInfo ( testSchema , complexInputType ) ;
361
+ const typeInfo = new TypeInfo ( schema , complexInputType ) ;
324
362
325
363
const visited : Array < any > = [ ] ;
326
364
visit (
0 commit comments