@@ -17,99 +17,146 @@ function typeOf(object) {
17
17
return / ( \b \w + \b ) \] / . exec ( Object . prototype . toString . call ( object ) ) [ 1 ] ;
18
18
}
19
19
20
- if ( typeof Symbol === 'function' && Symbol . toStringTag ) {
21
- describe ( 'Check to see if Symbol.toStringTag is defined on types' , ( ) => {
22
- const s = Symbol . toStringTag ;
23
- const hasSymbol = o => Object . getOwnPropertySymbols ( o ) . includes ( s ) ;
24
-
25
- it ( 'GraphQLDirective should have Symbol.toStringTag' , ( ) => {
26
- expect ( hasSymbol ( GraphQLDirective . prototype ) ) . to . equal ( true ) ;
27
- } ) ;
28
-
29
- it ( 'GraphQLEnumType should have Symbol.toStringTag' , ( ) => {
30
- expect ( hasSymbol ( GraphQLEnumType . prototype ) ) . to . equal ( true ) ;
31
- } ) ;
32
-
33
- it ( 'GraphQLInputObjectType should have Symbol.toStringTag' , ( ) => {
34
- expect ( hasSymbol ( GraphQLInputObjectType . prototype ) ) . to . equal ( true ) ;
35
- } ) ;
36
-
37
- it ( 'GraphQLInterfaceType should have Symbol.toStringTag' , ( ) => {
38
- expect ( hasSymbol ( GraphQLInterfaceType . prototype ) ) . to . equal ( true ) ;
39
- } ) ;
40
-
41
- it ( 'GraphQLObjectType should have Symbol.toStringTag' , ( ) => {
42
- expect ( hasSymbol ( GraphQLObjectType . prototype ) ) . to . equal ( true ) ;
43
- } ) ;
44
-
45
- it ( 'GraphQLScalarType should have Symbol.toStringTag' , ( ) => {
46
- expect ( hasSymbol ( GraphQLScalarType . prototype ) ) . to . equal ( true ) ;
47
- } ) ;
48
-
49
- it ( 'GraphQLSchema should have Symbol.toStringTag' , ( ) => {
50
- expect ( hasSymbol ( GraphQLSchema . prototype ) ) . to . equal ( true ) ;
51
- } ) ;
52
-
53
- it ( 'GraphQLUnionType should have Symbol.toStringTag' , ( ) => {
54
- expect ( hasSymbol ( GraphQLUnionType . prototype ) ) . to . equal ( true ) ;
55
- } ) ;
56
-
57
- it ( 'Source should have Symbol.toStringTag' , ( ) => {
58
- expect ( hasSymbol ( Source . prototype ) ) . to . equal ( true ) ;
59
- } ) ;
60
- } ) ;
61
-
62
- describe ( 'Check to see if Symbol.toStringTag tests on instances' , ( ) => {
63
- // variables _interface and _enum have preceding underscores due to being
64
- // reserved keywords in JavaScript
65
-
66
- const schema = buildSchema ( 'type Query { ignore: String }' ) ;
67
- const scalar = new GraphQLScalarType ( { name : 'Example' , serialize ( ) { } } ) ;
68
- const object = new GraphQLObjectType ( { name : 'Example' } ) ;
69
- const _interface = new GraphQLInterfaceType ( { name : 'Example' } ) ;
70
- const union = new GraphQLUnionType ( { name : 'Example' } ) ;
71
- const _enum = new GraphQLEnumType ( { name : 'Example' } ) ;
72
- const inputType = new GraphQLInputObjectType ( { name : 'Example' } ) ;
73
- const directive = new GraphQLDirective ( {
74
- name : 'Example' ,
75
- locations : [ 'OBJECT' ] ,
76
- } ) ;
77
- const source = new Source ( '{ doIt { now } }' ) ;
78
-
79
- it ( 'should return the class name for GraphQLSchema instance' , ( ) => {
80
- expect ( typeOf ( schema ) ) . to . equal ( GraphQLSchema . name ) ;
81
- } ) ;
82
-
83
- it ( 'should return the class name for GraphQLScalarType instance' , ( ) => {
84
- expect ( typeOf ( scalar ) ) . to . equal ( GraphQLScalarType . name ) ;
85
- } ) ;
86
-
87
- it ( 'should return the class name for GraphQLObjectType instance' , ( ) => {
88
- expect ( typeOf ( object ) ) . to . equal ( GraphQLObjectType . name ) ;
89
- } ) ;
90
-
91
- it ( 'should return the class name for GraphQLInterfaceType instance' , ( ) => {
92
- expect ( typeOf ( _interface ) ) . to . equal ( GraphQLInterfaceType . name ) ;
93
- } ) ;
94
-
95
- it ( 'should return the class name for GraphQLUnionType instance' , ( ) => {
96
- expect ( typeOf ( union ) ) . to . equal ( GraphQLUnionType . name ) ;
97
- } ) ;
98
-
99
- it ( 'should return the class name for GraphQLEnumType instance' , ( ) => {
100
- expect ( typeOf ( _enum ) ) . to . equal ( GraphQLEnumType . name ) ;
101
- } ) ;
102
-
103
- it ( 'should return the class name for GraphQLInputObjectType instance' , ( ) => {
104
- expect ( typeOf ( inputType ) ) . to . equal ( GraphQLInputObjectType . name ) ;
105
- } ) ;
106
-
107
- it ( 'should return the class name for GraphQLDirective instance' , ( ) => {
108
- expect ( typeOf ( directive ) ) . to . equal ( GraphQLDirective . name ) ;
109
- } ) ;
110
-
111
- it ( 'should return the class name for Source instance' , ( ) => {
112
- expect ( typeOf ( source ) ) . to . equal ( Source . name ) ;
113
- } ) ;
20
+ describe ( 'Check to see if Symbol.toStringTag is defined on types' , ( ) => {
21
+ const s = Symbol . toStringTag ;
22
+ const hasSymbol = o => Object . getOwnPropertySymbols ( o ) . includes ( s ) ;
23
+
24
+ it ( 'GraphQLDirective should have Symbol.toStringTag' , ( ) => {
25
+ expect ( hasSymbol ( GraphQLDirective ) ) . to . equal ( true ) ;
26
+ expect ( hasSymbol ( GraphQLDirective . prototype ) ) . to . equal ( true ) ;
114
27
} ) ;
115
- }
28
+
29
+ it ( 'GraphQLEnumType should have Symbol.toStringTag' , ( ) => {
30
+ expect ( hasSymbol ( GraphQLEnumType ) ) . to . equal ( true ) ;
31
+ expect ( hasSymbol ( GraphQLEnumType . prototype ) ) . to . equal ( true ) ;
32
+ } ) ;
33
+
34
+ it ( 'GraphQLInputObjectType should have Symbol.toStringTag' , ( ) => {
35
+ expect ( hasSymbol ( GraphQLInputObjectType ) ) . to . equal ( true ) ;
36
+ expect ( hasSymbol ( GraphQLInputObjectType . prototype ) ) . to . equal ( true ) ;
37
+ } ) ;
38
+
39
+ it ( 'GraphQLInterfaceType should have Symbol.toStringTag' , ( ) => {
40
+ expect ( hasSymbol ( GraphQLInterfaceType ) ) . to . equal ( true ) ;
41
+ expect ( hasSymbol ( GraphQLInterfaceType . prototype ) ) . to . equal ( true ) ;
42
+ } ) ;
43
+
44
+ it ( 'GraphQLObjectType should have Symbol.toStringTag' , ( ) => {
45
+ expect ( hasSymbol ( GraphQLObjectType ) ) . to . equal ( true ) ;
46
+ expect ( hasSymbol ( GraphQLObjectType . prototype ) ) . to . equal ( true ) ;
47
+ } ) ;
48
+
49
+ it ( 'GraphQLScalarType should have Symbol.toStringTag' , ( ) => {
50
+ expect ( hasSymbol ( GraphQLScalarType ) ) . to . equal ( true ) ;
51
+ expect ( hasSymbol ( GraphQLScalarType . prototype ) ) . to . equal ( true ) ;
52
+ } ) ;
53
+
54
+ it ( 'GraphQLSchema should have Symbol.toStringTag' , ( ) => {
55
+ expect ( hasSymbol ( GraphQLSchema ) ) . to . equal ( true ) ;
56
+ expect ( hasSymbol ( GraphQLSchema . prototype ) ) . to . equal ( true ) ;
57
+ } ) ;
58
+
59
+ it ( 'GraphQLUnionType should have Symbol.toStringTag' , ( ) => {
60
+ expect ( hasSymbol ( GraphQLUnionType ) ) . to . equal ( true ) ;
61
+ expect ( hasSymbol ( GraphQLUnionType . prototype ) ) . to . equal ( true ) ;
62
+ } ) ;
63
+
64
+ it ( 'Source should have Symbol.toStringTag' , ( ) => {
65
+ expect ( hasSymbol ( Source ) ) . to . equal ( true ) ;
66
+ expect ( hasSymbol ( Source . prototype ) ) . to . equal ( true ) ;
67
+ } ) ;
68
+ } ) ;
69
+
70
+ describe ( 'Check to see if Symbol.toStringTag tests on a class level' , ( ) => {
71
+ it ( 'should return the class name for GraphQLSchema' , ( ) => {
72
+ expect ( typeOf ( GraphQLSchema ) ) . to . equal ( GraphQLSchema . name ) ;
73
+ } ) ;
74
+
75
+ it ( 'should return the class name for GraphQLScalarType' , ( ) => {
76
+ expect ( typeOf ( GraphQLScalarType ) ) . to . equal ( GraphQLScalarType . name ) ;
77
+ } ) ;
78
+
79
+ it ( 'should return the class name for GraphQLObjectType' , ( ) => {
80
+ expect ( typeOf ( GraphQLObjectType ) ) . to . equal ( GraphQLObjectType . name ) ;
81
+ } ) ;
82
+
83
+ it ( 'should return the class name for GraphQLInterfaceType' , ( ) => {
84
+ expect ( typeOf ( GraphQLInterfaceType ) ) . to . equal ( GraphQLInterfaceType . name ) ;
85
+ } ) ;
86
+
87
+ it ( 'should return the class name for GraphQLUnionType' , ( ) => {
88
+ expect ( typeOf ( GraphQLUnionType ) ) . to . equal ( GraphQLUnionType . name ) ;
89
+ } ) ;
90
+
91
+ it ( 'should return the class name for GraphQLEnumType' , ( ) => {
92
+ expect ( typeOf ( GraphQLEnumType ) ) . to . equal ( GraphQLEnumType . name ) ;
93
+ } ) ;
94
+
95
+ it ( 'should return the class name for GraphQLInputObjectType' , ( ) => {
96
+ expect ( typeOf ( GraphQLInputObjectType ) ) . to . equal (
97
+ GraphQLInputObjectType . name ,
98
+ ) ;
99
+ } ) ;
100
+
101
+ it ( 'should return the class name for GraphQLDirective' , ( ) => {
102
+ expect ( typeOf ( GraphQLDirective ) ) . to . equal ( GraphQLDirective . name ) ;
103
+ } ) ;
104
+
105
+ it ( 'should return the class name for Source' , ( ) => {
106
+ expect ( typeOf ( Source ) ) . to . equal ( Source . name ) ;
107
+ } ) ;
108
+ } ) ;
109
+
110
+ describe ( 'Check to see if Symbol.toStringTag tests on instances' , ( ) => {
111
+ // variables _interface and _enum have preceding underscores due to being
112
+ // reserved keywords in JavaScript
113
+
114
+ const schema = buildSchema ( 'type Query { ignore: String }' ) ;
115
+ const scalar = new GraphQLScalarType ( { name : 'Example' , serialize ( ) { } } ) ;
116
+ const object = new GraphQLObjectType ( { name : 'Example' } ) ;
117
+ const _interface = new GraphQLInterfaceType ( { name : 'Example' } ) ;
118
+ const union = new GraphQLUnionType ( { name : 'Example' } ) ;
119
+ const _enum = new GraphQLEnumType ( { name : 'Example' } ) ;
120
+ const inputType = new GraphQLInputObjectType ( { name : 'Example' } ) ;
121
+ const directive = new GraphQLDirective ( {
122
+ name : 'Example' ,
123
+ locations : [ 'OBJECT' ] ,
124
+ } ) ;
125
+ const source = new Source ( '{ doIt { now } }' ) ;
126
+
127
+ it ( 'should return the class name for GraphQLSchema instance' , ( ) => {
128
+ expect ( typeOf ( schema ) ) . to . equal ( GraphQLSchema . name ) ;
129
+ } ) ;
130
+
131
+ it ( 'should return the class name for GraphQLScalarType instance' , ( ) => {
132
+ expect ( typeOf ( scalar ) ) . to . equal ( GraphQLScalarType . name ) ;
133
+ } ) ;
134
+
135
+ it ( 'should return the class name for GraphQLObjectType instance' , ( ) => {
136
+ expect ( typeOf ( object ) ) . to . equal ( GraphQLObjectType . name ) ;
137
+ } ) ;
138
+
139
+ it ( 'should return the class name for GraphQLInterfaceType instance' , ( ) => {
140
+ expect ( typeOf ( _interface ) ) . to . equal ( GraphQLInterfaceType . name ) ;
141
+ } ) ;
142
+
143
+ it ( 'should return the class name for GraphQLUnionType instance' , ( ) => {
144
+ expect ( typeOf ( union ) ) . to . equal ( GraphQLUnionType . name ) ;
145
+ } ) ;
146
+
147
+ it ( 'should return the class name for GraphQLEnumType instance' , ( ) => {
148
+ expect ( typeOf ( _enum ) ) . to . equal ( GraphQLEnumType . name ) ;
149
+ } ) ;
150
+
151
+ it ( 'should return the class name for GraphQLInputObjectType instance' , ( ) => {
152
+ expect ( typeOf ( inputType ) ) . to . equal ( GraphQLInputObjectType . name ) ;
153
+ } ) ;
154
+
155
+ it ( 'should return the class name for GraphQLDirective instance' , ( ) => {
156
+ expect ( typeOf ( directive ) ) . to . equal ( GraphQLDirective . name ) ;
157
+ } ) ;
158
+
159
+ it ( 'should return the class name for Source instance' , ( ) => {
160
+ expect ( typeOf ( source ) ) . to . equal ( Source . name ) ;
161
+ } ) ;
162
+ } ) ;
0 commit comments