Skip to content

Commit

Permalink
Added test that proofs that 833 is fixed. (#2587)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Nov 16, 2020
1 parent e7774b9 commit 39ff240
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Expand Up @@ -4,6 +4,7 @@
using Snapshooter.Xunit;
using Xunit;
using System.Threading.Tasks;
using Snapshooter;

namespace HotChocolate.Types.SDL
{
Expand Down Expand Up @@ -181,6 +182,35 @@ enum Greetings {
.MatchSnapshotAsync();
}

// https://github.com/ChilliCream/hotchocolate/issues/833
[InlineData("GOOD_EVENING")]
[InlineData("GOODEVENING")]
[Theory]
public async Task Try_Using_A_Enum_Value_That_Is_Not_Bound(string value)
{
// arrange
Snapshot.FullName(new SnapshotNameExtension(value));

var sdl =
@"type Query {
hello(greetings: Greetings): Greetings
}
enum Greetings {
GOOD_MORNING
}";

// act
// assert
await new ServiceCollection()
.AddGraphQL()
.AddDocumentFromString(sdl)
.BindComplexType<Query>()
.BindEnumType<Greetings>()
.ExecuteRequestAsync($"{{ hello(greetings: \"{value}\") }}")
.MatchSnapshotAsync();
}

public class Query
{
public Greetings Hello(Greetings greetings) => greetings;
Expand Down
@@ -0,0 +1,22 @@
{
"errors": [
{
"message": "The specified argument value does not match the argument type.",
"locations": [
{
"line": 1,
"column": 20
}
],
"path": [
"hello"
],
"extensions": {
"argument": "greetings",
"argumentValue": "\u0022GOODEVENING\u0022",
"locationType": "Greetings",
"specifiedBy": "http://spec.graphql.org/June2018/#sec-Values-of-Correct-Type"
}
}
]
}
@@ -0,0 +1,22 @@
{
"errors": [
{
"message": "The specified argument value does not match the argument type.",
"locations": [
{
"line": 1,
"column": 20
}
],
"path": [
"hello"
],
"extensions": {
"argument": "greetings",
"argumentValue": "\u0022GOOD_EVENING\u0022",
"locationType": "Greetings",
"specifiedBy": "http://spec.graphql.org/June2018/#sec-Values-of-Correct-Type"
}
}
]
}

0 comments on commit 39ff240

Please sign in to comment.