From c47745ea762938a62b3e6d102a88d627f348a8e2 Mon Sep 17 00:00:00 2001 From: Alexandr Viniychuk Date: Mon, 12 Dec 2016 00:45:20 -0500 Subject: [PATCH] updated tests for nullable enums --- Tests/Library/Type/EnumTypeTest.php | 2 +- Tests/Schema/InputObjectDefaultValuesTest.php | 4 +++- examples/js/index.js | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Tests/Library/Type/EnumTypeTest.php b/Tests/Library/Type/EnumTypeTest.php index c6f356ac..c6969712 100644 --- a/Tests/Library/Type/EnumTypeTest.php +++ b/Tests/Library/Type/EnumTypeTest.php @@ -120,7 +120,7 @@ public function testNormalCreatingParams() $this->assertEquals($enumType->getNamedType(), $enumType); $this->assertFalse($enumType->isValidValue($enumType)); - $this->assertFalse($enumType->isValidValue(null)); + $this->assertTrue($enumType->isValidValue(null)); $this->assertTrue($enumType->isValidValue(true)); $this->assertTrue($enumType->isValidValue('disable')); diff --git a/Tests/Schema/InputObjectDefaultValuesTest.php b/Tests/Schema/InputObjectDefaultValuesTest.php index bc217c65..491a69cf 100644 --- a/Tests/Schema/InputObjectDefaultValuesTest.php +++ b/Tests/Schema/InputObjectDefaultValuesTest.php @@ -91,7 +91,9 @@ public function testDefaultEnum() $result = $processor->getResponseData(); $this->assertEquals(['data' => [ - 'enumObject' => null + 'enumObject' => [ + 'status' => null + ] ]], $result); } diff --git a/examples/js/index.js b/examples/js/index.js index 1ad22ddd..257147f0 100644 --- a/examples/js/index.js +++ b/examples/js/index.js @@ -180,6 +180,12 @@ const blogSchema = new GraphQLSchema({ return [DataProvider.getPost(2), DataProvider.getBanner(3)]; } }, + enumNull: { + type: postStatus, + resolve: () => { + return null; + } + }, scalarList: { type: new GraphQLList(new GraphQLObjectType({ name: 'scalarObject', @@ -224,7 +230,7 @@ const blogSchema = new GraphQLSchema({ }) }); -var query = '{ scalarList(count: 12) { id, cost } }'; +var query = '{ enumNull }'; graphql(blogSchema, query).then(result => { console.log(JSON.stringify(result, null, 5)); process.exit(0);