Skip to content

Commit de614b1

Browse files
authored
add additional mapSchemaConfig tests (graphql#4571)
1 parent bd6dbfe commit de614b1

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/utilities/__tests__/mapSchemaConfig-test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,58 @@ describe('mapSchemaConfig', () => {
112112
);
113113
});
114114

115+
it('can map fields with non-null return type', () => {
116+
const sdl = `
117+
type SomeType {
118+
field: String!
119+
}
120+
`;
121+
122+
const schemaConfig = buildSchema(sdl).toConfig();
123+
124+
expectSchemaMapping(
125+
schemaConfig,
126+
() => ({
127+
[SchemaElementKind.FIELD]: (config) => ({
128+
...config,
129+
description: 'Some description',
130+
}),
131+
}),
132+
`
133+
type SomeType {
134+
"""Some description"""
135+
field: String!
136+
}
137+
`,
138+
);
139+
});
140+
141+
it('can map fields with list return type', () => {
142+
const sdl = `
143+
type SomeType {
144+
field: [String]
145+
}
146+
`;
147+
148+
const schemaConfig = buildSchema(sdl).toConfig();
149+
150+
expectSchemaMapping(
151+
schemaConfig,
152+
() => ({
153+
[SchemaElementKind.FIELD]: (config) => ({
154+
...config,
155+
description: 'Some description',
156+
}),
157+
}),
158+
`
159+
type SomeType {
160+
"""Some description"""
161+
field: [String]
162+
}
163+
`,
164+
);
165+
});
166+
115167
it('maps fields after mapping arguments', () => {
116168
const sdl = `
117169
type SomeType {

0 commit comments

Comments
 (0)