Skip to content

Commit ae5201a

Browse files
committed
add a test case for empty schema
1 parent 58ceb54 commit ae5201a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/__snapshots__/code-generator.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,18 @@ export type OptionalNode = OptionalBook | OptionalAuthor;
5151
5252
"
5353
`;
54+
55+
exports[`generateCode > generates code when empty typeInfos is passed 1`] = `
56+
"import {
57+
type DefineTypeFactoryInterface,
58+
defineTypeFactory,
59+
} from '@mizdra/graphql-codegen-typescript-fabbrica/helper';
60+
import type {
61+
Maybe,
62+
,
63+
} from './types';
64+
65+
export * from '@mizdra/graphql-codegen-typescript-fabbrica/helper';
66+
67+
"
68+
`;

src/code-generator.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,13 @@ describe('generateCode', () => {
7373
const actual = generateCode(config, typeInfos);
7474
expect(actual).toMatchSnapshot();
7575
});
76+
it('generates code when empty typeInfos is passed', () => {
77+
const config = fakeConfig({
78+
typesFile: './types',
79+
skipTypename: oneOf([true, false]),
80+
});
81+
const typeInfos: TypeInfo[] = [];
82+
const actual = generateCode(config, typeInfos);
83+
expect(actual).toMatchSnapshot();
84+
});
7685
});

src/schema-scanner.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ describe('getTypeInfos', () => {
7777
]
7878
`);
7979
});
80+
it('returns empty array when schema without type is passed', () => {
81+
const schema = buildSchema(`
82+
scalar Date
83+
`);
84+
const config: Config = fakeConfig();
85+
expect(getTypeInfos(config, schema)).toMatchInlineSnapshot(`[]`);
86+
});
8087
it('includes description comment', () => {
8188
const schema = buildSchema(`
8289
"The book"

0 commit comments

Comments
 (0)