Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
test: start coverage of core renderer module
Browse files Browse the repository at this point in the history
Relates to #373
  • Loading branch information
jasonkuhrt committed Dec 31, 2018
1 parent 60a8b90 commit 0199cca
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 2 deletions.
147 changes: 147 additions & 0 deletions packages/graphqlgen/src/generators/common.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import * as Common from './common'

it('deepResolveInputTypes', () => {
const typeMap: Common.InputTypesMap = {
A: {
name: 'A',
type: {
name: 'A',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
},
fields: [
{
name: 'b',
arguments: [],
type: {
name: 'B',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
isRequired: false,
isArray: false,
},
},
{
name: 'c',
arguments: [],
type: {
name: 'C',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
isRequired: false,
isArray: false,
},
},
],
},
B: {
name: 'B',
type: {
name: 'B',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
},
fields: [
{
name: 'd',
arguments: [],
type: {
name: 'D',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
isRequired: false,
isArray: false,
},
},
],
},
C: {
name: 'C',
type: {
name: 'C',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
},
fields: [
{
name: 'd',
arguments: [],
type: {
name: 'D',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
isRequired: false,
isArray: false,
},
},
],
},
D: {
name: 'D',
type: {
name: 'D',
isInput: true,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: false,
isUnion: false,
},
fields: [
{
name: 'foo',
arguments: [],
type: {
name: 'String',
isInput: false,
isEnum: false,
isInterface: false,
isObject: false,
isScalar: true,
isUnion: false,
isRequired: false,
isArray: false,
},
},
],
},
}

expect(Common.deepResolveInputTypes(typeMap, 'A')).toMatchInlineSnapshot(`
Array [
"A",
"B",
"D",
"C",
"D",
]
`)
})
4 changes: 2 additions & 2 deletions packages/graphqlgen/src/generators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ export function getTypeFromGraphQLType(
return 'string'
}

function deepResolveInputTypes(
export function deepResolveInputTypes(
inputTypesMap: InputTypesMap,
typeName: string,
seen: { [k: string]: boolean } = {},
seen: Record<string, boolean> = {},
): string[] {
const type = inputTypesMap[typeName]
if (type) {
Expand Down

0 comments on commit 0199cca

Please sign in to comment.