@@ -95,4 +95,66 @@ describe('Type System: Schema', () => {
95
95
expect ( Schema . getTypeMap ( ) ) . to . include . key ( 'WrappedDirInput' ) ;
96
96
} ) ;
97
97
} ) ;
98
+
99
+ describe ( 'Validity' , ( ) => {
100
+ describe ( 'when not assumed valid' , ( ) => {
101
+ it ( 'configures the schema to still needing validation' , ( ) => {
102
+ expect (
103
+ new GraphQLSchema ( {
104
+ assumeValid : false ,
105
+ } ) . __validationErrors ,
106
+ ) . to . equal ( undefined ) ;
107
+ } ) ;
108
+
109
+ it ( 'configures the schema for allowed legacy names' , ( ) => {
110
+ expect (
111
+ new GraphQLSchema ( {
112
+ allowedLegacyNames : [ '__badName' ] ,
113
+ } ) . __allowedLegacyNames ,
114
+ ) . to . deep . equal ( [ '__badName' ] ) ;
115
+ } ) ;
116
+
117
+ it ( 'checks the configuration for mistakes' , ( ) => {
118
+ expect ( ( ) => new GraphQLSchema ( ( ) => null ) ) . to . throw ( ) ;
119
+ expect ( ( ) => new GraphQLSchema ( { types : { } } ) ) . to . throw ( ) ;
120
+ expect ( ( ) => new GraphQLSchema ( { directives : { } } ) ) . to . throw ( ) ;
121
+ expect ( ( ) => new GraphQLSchema ( { allowedLegacyNames : { } } ) ) . to . throw ( ) ;
122
+ } ) ;
123
+ } ) ;
124
+
125
+ describe ( 'when assumed valid' , ( ) => {
126
+ it ( 'configures the schema to have no errors' , ( ) => {
127
+ expect (
128
+ new GraphQLSchema ( {
129
+ assumeValid : true ,
130
+ } ) . __validationErrors ,
131
+ ) . to . deep . equal ( [ ] ) ;
132
+ } ) ;
133
+
134
+ it ( 'still configures the schema for allowed legacy names' , ( ) => {
135
+ expect (
136
+ new GraphQLSchema ( {
137
+ assumeValid : true ,
138
+ allowedLegacyNames : [ '__badName' ] ,
139
+ } ) . __allowedLegacyNames ,
140
+ ) . to . deep . equal ( [ '__badName' ] ) ;
141
+ } ) ;
142
+
143
+ it ( 'does not check the configuration for mistakes' , ( ) => {
144
+ expect ( ( ) => {
145
+ const config = ( ) => null ;
146
+ config . assumeValid = true ;
147
+ return new GraphQLSchema ( config ) ;
148
+ } ) . to . not . throw ( ) ;
149
+ expect ( ( ) => {
150
+ return new GraphQLSchema ( {
151
+ assumeValid : true ,
152
+ types : { } ,
153
+ directives : { reduce : ( ) => [ ] } ,
154
+ allowedLegacyNames : { } ,
155
+ } ) ;
156
+ } ) . to . not . throw ( ) ;
157
+ } ) ;
158
+ } ) ;
159
+ } ) ;
98
160
} ) ;
0 commit comments