From a75e95b873575434910c215a69ddcc3ac9000ac2 Mon Sep 17 00:00:00 2001 From: Saihajpreet Singh Date: Wed, 14 Apr 2021 15:10:22 -0500 Subject: [PATCH] simplify predicate-test type (#3039) Co-authored-by: Ivan Goncharov --- src/type/__tests__/predicate-test.js | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/type/__tests__/predicate-test.js b/src/type/__tests__/predicate-test.js index 73400f6294..f94bed1030 100644 --- a/src/type/__tests__/predicate-test.js +++ b/src/type/__tests__/predicate-test.js @@ -1,7 +1,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import type { GraphQLArgument, GraphQLInputField } from '../definition'; +import type { + GraphQLArgument, + GraphQLInputField, + GraphQLInputType, +} from '../definition'; import { GraphQLDirective, GraphQLSkipDirective, @@ -503,7 +507,7 @@ describe('Type predicates', () => { describe('getNullableType', () => { it('returns undefined for no type', () => { - expect(getNullableType()).to.equal(undefined); + expect(getNullableType(undefined)).to.equal(undefined); expect(getNullableType(null)).to.equal(undefined); }); @@ -536,7 +540,7 @@ describe('Type predicates', () => { describe('getNamedType', () => { it('returns undefined for no type', () => { - expect(getNamedType()).to.equal(undefined); + expect(getNamedType(undefined)).to.equal(undefined); expect(getNamedType(null)).to.equal(undefined); }); @@ -559,15 +563,18 @@ describe('Type predicates', () => { }); describe('isRequiredArgument', () => { - function buildArg(config: $Shape): GraphQLArgument { + function buildArg(config: {| + type: GraphQLInputType, + defaultValue?: mixed, + |}): GraphQLArgument { return { name: 'someArg', + type: config.type, description: undefined, - defaultValue: undefined, + defaultValue: config.defaultValue, deprecationReason: null, extensions: undefined, astNode: undefined, - ...config, }; } @@ -604,17 +611,18 @@ describe('Type predicates', () => { }); describe('isRequiredInputField', () => { - function buildInputField( - config: $Shape, - ): GraphQLInputField { + function buildInputField(config: {| + type: GraphQLInputType, + defaultValue?: mixed, + |}): GraphQLInputField { return { name: 'someInputField', + type: config.type, description: undefined, - defaultValue: undefined, + defaultValue: config.defaultValue, deprecationReason: null, extensions: undefined, astNode: undefined, - ...config, }; }