@@ -31,116 +31,147 @@ describe('resolveSchemaCoordinate', () => {
31
31
` ) ;
32
32
33
33
it ( 'resolves a Named Type' , ( ) => {
34
- const expected = schema . getType ( 'Business' ) ;
35
- expect ( expected ) . not . to . equal ( undefined ) ;
36
- expect ( resolveSchemaCoordinate ( schema , 'Business' ) ) . to . equal ( expected ) ;
34
+ expect ( resolveSchemaCoordinate ( schema , 'Business' ) ) . to . deep . equal ( {
35
+ kind : 'NamedType' ,
36
+ type : schema . getType ( 'Business' ) ,
37
+ } ) ;
37
38
38
- expect ( resolveSchemaCoordinate ( schema , 'String' ) ) . to . equal (
39
- schema . getType ( 'String' ) ,
40
- ) ;
39
+ expect ( resolveSchemaCoordinate ( schema , 'String' ) ) . to . deep . equal ( {
40
+ kind : 'NamedType' ,
41
+ type : schema . getType ( 'String' ) ,
42
+ } ) ;
41
43
42
- expect ( resolveSchemaCoordinate ( schema , 'private' ) ) . to . equal ( undefined ) ;
44
+ expect ( resolveSchemaCoordinate ( schema , 'private' ) ) . to . deep . equal ( undefined ) ;
43
45
44
- expect ( resolveSchemaCoordinate ( schema , 'Unknown' ) ) . to . equal ( undefined ) ;
46
+ expect ( resolveSchemaCoordinate ( schema , 'Unknown' ) ) . to . deep . equal ( undefined ) ;
45
47
} ) ;
46
48
47
49
it ( 'resolves a Type Field' , ( ) => {
48
- const expected = schema . getType ( 'Business' ) . getFields ( ) . name ;
49
- expect ( expected ) . not . to . equal ( undefined ) ;
50
- expect ( resolveSchemaCoordinate ( schema , 'Business.name' ) ) . to . equal ( expected ) ;
51
-
52
- expect ( resolveSchemaCoordinate ( schema , 'Business.unknown' ) ) . to . equal (
50
+ const type = schema . getType ( 'Business' ) ;
51
+ const field = type . getFields ( ) . name ;
52
+ expect ( resolveSchemaCoordinate ( schema , 'Business.name' ) ) . to . deep . equal ( {
53
+ kind : 'Field' ,
54
+ type,
55
+ field,
56
+ } ) ;
57
+
58
+ expect ( resolveSchemaCoordinate ( schema , 'Business.unknown' ) ) . to . deep . equal (
53
59
undefined ,
54
60
) ;
55
61
56
- expect ( resolveSchemaCoordinate ( schema , 'Unknown.field' ) ) . to . equal (
62
+ expect ( resolveSchemaCoordinate ( schema , 'Unknown.field' ) ) . to . deep . equal (
57
63
undefined ,
58
64
) ;
59
65
60
- expect ( resolveSchemaCoordinate ( schema , 'String.field' ) ) . to . equal ( undefined ) ;
66
+ expect ( resolveSchemaCoordinate ( schema , 'String.field' ) ) . to . deep . equal (
67
+ undefined ,
68
+ ) ;
61
69
} ) ;
62
70
63
71
it ( 'does not resolve meta-fields' , ( ) => {
64
- expect ( resolveSchemaCoordinate ( schema , 'Business.__typename' ) ) . to . equal (
65
- undefined ,
66
- ) ;
72
+ expect (
73
+ resolveSchemaCoordinate ( schema , 'Business.__typename' ) ,
74
+ ) . to . deep . equal ( undefined ) ;
67
75
} ) ;
68
76
69
77
it ( 'resolves a Input Field' , ( ) => {
70
- const expected = schema . getType ( 'SearchCriteria' ) . getFields ( ) . filter ;
71
- expect ( expected ) . not . to . equal ( undefined ) ;
72
- expect ( resolveSchemaCoordinate ( schema , 'SearchCriteria.filter' ) ) . to . equal (
73
- expected ,
74
- ) ;
78
+ const type = schema . getType ( 'SearchCriteria' ) ;
79
+ const inputField = type . getFields ( ) . filter ;
80
+ expect (
81
+ resolveSchemaCoordinate ( schema , 'SearchCriteria.filter' ) ,
82
+ ) . to . deep . equal ( {
83
+ kind : 'InputField' ,
84
+ type,
85
+ inputField,
86
+ } ) ;
75
87
76
- expect ( resolveSchemaCoordinate ( schema , 'SearchCriteria.unknown' ) ) . to . equal (
77
- undefined ,
78
- ) ;
88
+ expect (
89
+ resolveSchemaCoordinate ( schema , 'SearchCriteria.unknown' ) ,
90
+ ) . to . deep . equal ( undefined ) ;
79
91
} ) ;
80
92
81
93
it ( 'resolves a Enum Value' , ( ) => {
82
- const expected = schema . getType ( 'SearchFilter' ) . getValue ( 'OPEN_NOW' ) ;
83
- expect ( expected ) . not . to . equal ( undefined ) ;
84
- expect ( resolveSchemaCoordinate ( schema , 'SearchFilter.OPEN_NOW' ) ) . to . equal (
85
- expected ,
86
- ) ;
94
+ const type = schema . getType ( 'SearchFilter' ) ;
95
+ const enumValue = type . getValue ( 'OPEN_NOW' ) ;
96
+ expect (
97
+ resolveSchemaCoordinate ( schema , 'SearchFilter.OPEN_NOW' ) ,
98
+ ) . to . deep . equal ( {
99
+ kind : 'EnumValue' ,
100
+ type,
101
+ enumValue,
102
+ } ) ;
87
103
88
- expect ( resolveSchemaCoordinate ( schema , 'SearchFilter.UNKNOWN' ) ) . to . equal (
89
- undefined ,
90
- ) ;
104
+ expect (
105
+ resolveSchemaCoordinate ( schema , 'SearchFilter.UNKNOWN' ) ,
106
+ ) . to . deep . equal ( undefined ) ;
91
107
} ) ;
92
108
93
109
it ( 'resolves a Field Argument' , ( ) => {
94
- const expected = schema
95
- . getType ( 'Query' )
96
- . getFields ( )
97
- . searchBusiness . args . find ( ( arg ) => arg . name === 'criteria' ) ;
98
- expect ( expected ) . not . to . equal ( undefined ) ;
110
+ const type = schema . getType ( 'Query' ) ;
111
+ const field = type . getFields ( ) . searchBusiness ;
112
+ const fieldArgument = field . args . find ( ( arg ) => arg . name === 'criteria' ) ;
99
113
expect (
100
114
resolveSchemaCoordinate ( schema , 'Query.searchBusiness(criteria:)' ) ,
101
- ) . to . equal ( expected ) ;
115
+ ) . to . deep . equal ( {
116
+ kind : 'FieldArgument' ,
117
+ type,
118
+ field,
119
+ fieldArgument,
120
+ } ) ;
102
121
103
- expect ( resolveSchemaCoordinate ( schema , 'Business.name(unknown:)' ) ) . to . equal (
104
- undefined ,
105
- ) ;
122
+ expect (
123
+ resolveSchemaCoordinate ( schema , 'Business.name(unknown:)' ) ,
124
+ ) . to . deep . equal ( undefined ) ;
106
125
107
- expect ( resolveSchemaCoordinate ( schema , 'Unknown.field(arg:)' ) ) . to . equal (
108
- undefined ,
109
- ) ;
126
+ expect (
127
+ resolveSchemaCoordinate ( schema , 'Unknown.field(arg:)' ) ,
128
+ ) . to . deep . equal ( undefined ) ;
110
129
111
- expect ( resolveSchemaCoordinate ( schema , 'Business.unknown(arg:)' ) ) . to . equal (
112
- undefined ,
113
- ) ;
130
+ expect (
131
+ resolveSchemaCoordinate ( schema , 'Business.unknown(arg:)' ) ,
132
+ ) . to . deep . equal ( undefined ) ;
114
133
115
134
expect (
116
135
resolveSchemaCoordinate ( schema , 'SearchCriteria.name(arg:)' ) ,
117
- ) . to . equal ( undefined ) ;
136
+ ) . to . deep . equal ( undefined ) ;
118
137
} ) ;
119
138
120
139
it ( 'resolves a Directive' , ( ) => {
121
- const expected = schema . getDirective ( 'private' ) ;
122
- expect ( expected ) . not . to . equal ( undefined ) ;
123
- expect ( resolveSchemaCoordinate ( schema , '@private' ) ) . to . equal ( expected ) ;
140
+ expect ( resolveSchemaCoordinate ( schema , '@private' ) ) . to . deep . equal ( {
141
+ kind : 'Directive' ,
142
+ directive : schema . getDirective ( 'private' ) ,
143
+ } ) ;
124
144
125
- expect ( resolveSchemaCoordinate ( schema , '@unknown' ) ) . to . equal ( undefined ) ;
145
+ expect ( resolveSchemaCoordinate ( schema , '@deprecated' ) ) . to . deep . equal ( {
146
+ kind : 'Directive' ,
147
+ directive : schema . getDirective ( 'deprecated' ) ,
148
+ } ) ;
126
149
127
- expect ( resolveSchemaCoordinate ( schema , '@Business' ) ) . to . equal ( undefined ) ;
150
+ expect ( resolveSchemaCoordinate ( schema , '@unknown' ) ) . to . deep . equal (
151
+ undefined ,
152
+ ) ;
153
+
154
+ expect ( resolveSchemaCoordinate ( schema , '@Business' ) ) . to . deep . equal (
155
+ undefined ,
156
+ ) ;
128
157
} ) ;
129
158
130
159
it ( 'resolves a Directive Argument' , ( ) => {
131
- const expected = schema
132
- . getDirective ( 'private' )
133
- . args . find ( ( arg ) => arg . name === 'scope' ) ;
134
- expect ( expected ) . not . to . equal ( undefined ) ;
135
- expect ( resolveSchemaCoordinate ( schema , '@private(scope:)' ) ) . to . equal (
136
- expected ,
160
+ const directive = schema . getDirective ( 'private' ) ;
161
+ const directiveArgument = directive . args . find (
162
+ ( arg ) => arg . name === 'scope' ,
137
163
) ;
164
+ expect ( resolveSchemaCoordinate ( schema , '@private(scope:)' ) ) . to . deep . equal ( {
165
+ kind : 'DirectiveArgument' ,
166
+ directive,
167
+ directiveArgument,
168
+ } ) ;
138
169
139
- expect ( resolveSchemaCoordinate ( schema , '@private(unknown:)' ) ) . to . equal (
170
+ expect ( resolveSchemaCoordinate ( schema , '@private(unknown:)' ) ) . to . deep . equal (
140
171
undefined ,
141
172
) ;
142
173
143
- expect ( resolveSchemaCoordinate ( schema , '@unknown(arg:)' ) ) . to . equal (
174
+ expect ( resolveSchemaCoordinate ( schema , '@unknown(arg:)' ) ) . to . deep . equal (
144
175
undefined ,
145
176
) ;
146
177
} ) ;
0 commit comments