Skip to content

Commit

Permalink
Improved KnownArgumentNames tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sogko authored and chris-ramon committed Mar 15, 2017
1 parent 4b534a6 commit da2a648
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rules_known_argument_names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ func TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalid(t *testing.T) {
testutil.RuleError(`Unknown argument "unless" on directive "@skip".`, 3, 19),
})
}
func TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalidWithSuggestion(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
{
dog @skip(of: true)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "of" on directive "@skip". `+
`Did you mean "if"?`, 3, 19),
})
}
func TestValidate_KnownArgumentNames_InvalidArgName(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
fragment invalidArgName on Dog {
Expand All @@ -94,6 +104,16 @@ func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs(t *testing.T) {
testutil.RuleError(`Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".`, 3, 55),
})
}
func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgsWithSuggestions(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
fragment oneGoodArgOneInvalidArg on Dog {
doesKnowCommand(ddogCommand: SIT,)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "ddogCommand" on field "doesKnowCommand" of type "Dog". `+
`Did you mean "dogCommand"?`, 3, 25),
})
}
func TestValidate_KnownArgumentNames_UnknownArgsDeeply(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
{
Expand Down

0 comments on commit da2a648

Please sign in to comment.