From be90c0a57ffad47400e0cc11c96e240893111ee9 Mon Sep 17 00:00:00 2001 From: spawnia Date: Thu, 7 Nov 2024 16:24:35 +0100 Subject: [PATCH] Add explicit test for `@enum` directive https://github.com/nuwave/lighthouse/issues/2629 --- .../Schema/Directives/EnumDirectiveTest.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/Integration/Schema/Directives/EnumDirectiveTest.php diff --git a/tests/Integration/Schema/Directives/EnumDirectiveTest.php b/tests/Integration/Schema/Directives/EnumDirectiveTest.php new file mode 100644 index 000000000..1fb059596 --- /dev/null +++ b/tests/Integration/Schema/Directives/EnumDirectiveTest.php @@ -0,0 +1,40 @@ +mockResolver(function ($_, array $args): string { + $this->assertSame('Active internal', $args['status']); + + return 'Not active'; + }); + + $this->schema = /** @lang GraphQL */ ' + enum Status { + ACTIVE @enum(value: "Active internal") + INACTIVE @enum(value: "Not active") + } + + type Query { + status(status: Status!): Status! @mock + } + '; + + $this + ->graphQL(/** @lang GraphQL */ ' + { + status(status: ACTIVE) + } + ') + ->assertExactJson([ + 'data' => [ + 'status' => 'INACTIVE', + ] + ]); + } +}