Skip to content

Commit 8c1f318

Browse files
committed
Improved KnownArgumentNames tests for coverage
1 parent 73f83b4 commit 8c1f318

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

rules_known_argument_names_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ func TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalid(t *testing.T) {
7575
testutil.RuleError(`Unknown argument "unless" on directive "@skip".`, 3, 19),
7676
})
7777
}
78+
func TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalidWithSuggestion(t *testing.T) {
79+
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
80+
{
81+
dog @skip(of: true)
82+
}
83+
`, []gqlerrors.FormattedError{
84+
testutil.RuleError(`Unknown argument "of" on directive "@skip". `+
85+
`Did you mean "if"?`, 3, 19),
86+
})
87+
}
7888
func TestValidate_KnownArgumentNames_InvalidArgName(t *testing.T) {
7989
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
8090
fragment invalidArgName on Dog {
@@ -94,6 +104,16 @@ func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs(t *testing.T) {
94104
testutil.RuleError(`Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".`, 3, 55),
95105
})
96106
}
107+
func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgsWithSuggestions(t *testing.T) {
108+
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
109+
fragment oneGoodArgOneInvalidArg on Dog {
110+
doesKnowCommand(ddogCommand: SIT,)
111+
}
112+
`, []gqlerrors.FormattedError{
113+
testutil.RuleError(`Unknown argument "ddogCommand" on field "doesKnowCommand" of type "Dog". `+
114+
`Did you mean "dogCommand"?`, 3, 25),
115+
})
116+
}
97117
func TestValidate_KnownArgumentNames_UnknownArgsDeeply(t *testing.T) {
98118
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
99119
{

0 commit comments

Comments
 (0)