Skip to content

Commit

Permalink
updated tests for nullable enums
Browse files Browse the repository at this point in the history
  • Loading branch information
viniychuk committed Dec 12, 2016
1 parent ae62f41 commit c47745e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tests/Library/Type/EnumTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 3 additions & 1 deletion Tests/Schema/InputObjectDefaultValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public function testDefaultEnum()
$result = $processor->getResponseData();

$this->assertEquals(['data' => [
'enumObject' => null
'enumObject' => [
'status' => null
]
]], $result);
}

Expand Down
8 changes: 7 additions & 1 deletion examples/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c47745e

Please sign in to comment.