@@ -3,6 +3,9 @@ package graphql.language
33import graphql.util.TraversalControl
44import graphql.util.TraverserContext
55import spock.lang.Specification
6+ import spock.lang.Unroll
7+
8+ import static java.util.Collections.emptyList
69
710class NodeVisitorStubTest extends Specification {
811
@@ -221,4 +224,39 @@ class NodeVisitorStubTest extends Specification {
221224 control == TraversalControl . QUIT
222225 }
223226
227+ @Unroll
228+ def " default for #visitMethod is to call visitNode" () {
229+ given :
230+ NodeVisitorStub nodeVisitorStub = Spy (NodeVisitorStub , constructorArgs : [])
231+ TraverserContext context = Mock (TraverserContext )
232+
233+ when :
234+ def control = nodeVisitorStub. " $visitMethod " (node, context)
235+ then :
236+ 1 * nodeVisitorStub. visitNode(node, context) >> TraversalControl . QUIT
237+ control == TraversalControl . QUIT
238+
239+ where :
240+ node | visitMethod
241+ new Argument (" " , null ) | ' visitArgument'
242+ new Directive (" " , emptyList()) | ' visitDirective'
243+ new DirectiveLocation (" " ) | ' visitDirectiveLocation'
244+ new Document () | ' visitDocument'
245+ new EnumValueDefinition (" " ) | ' visitEnumValueDefinition'
246+ new FieldDefinition (" " ) | ' visitFieldDefinition'
247+ new InputValueDefinition (" " ) | ' visitInputValueDefinition'
248+ new InputValueDefinition (" " ) | ' visitInputValueDefinition'
249+ new ObjectField (" " , null ) | ' visitObjectField'
250+ new OperationTypeDefinition () | ' visitOperationTypeDefinition'
251+ new OperationTypeDefinition () | ' visitOperationTypeDefinition'
252+ new SelectionSet () | ' visitSelectionSet'
253+ new VariableDefinition () | ' visitVariableDefinition'
254+ new StringValue (" " ) | ' visitValue'
255+ new OperationDefinition () | ' visitDefinition'
256+ new UnionTypeDefinition (" " ) | ' visitTypeDefinition'
257+ new Field () | ' visitSelection'
258+ new NonNullType () | ' visitType'
259+
260+ }
261+
224262}
0 commit comments