Skip to content

Commit

Permalink
simplify predicate-test type (#3039)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Goncharov <[email protected]>
  • Loading branch information
saihaj and IvanGoncharov authored Apr 14, 2021
1 parent 33e3a33 commit a75e95b
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/type/__tests__/predicate-test.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand All @@ -559,15 +563,18 @@ describe('Type predicates', () => {
});

describe('isRequiredArgument', () => {
function buildArg(config: $Shape<GraphQLArgument>): 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,
};
}

Expand Down Expand Up @@ -604,17 +611,18 @@ describe('Type predicates', () => {
});

describe('isRequiredInputField', () => {
function buildInputField(
config: $Shape<GraphQLInputField>,
): 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,
};
}

Expand Down

0 comments on commit a75e95b

Please sign in to comment.