Skip to content

Commit 62f03d7

Browse files
committed
Create standalone test
1 parent ecee891 commit 62f03d7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { validateTs } from '@graphql-codegen/testing';
2+
import { buildSchema, parse } from 'graphql';
3+
import { plugin } from '../src/index.js';
4+
5+
describe('TypeScript Operations Plugin - Standalone', () => {
6+
it('generates using default config', async () => {
7+
const schema = buildSchema(/* GraphQL */ `
8+
type Query {
9+
user(id: ID!): User
10+
}
11+
12+
type User {
13+
id: ID!
14+
name: String!
15+
role: UserRole!
16+
}
17+
18+
enum UserRole {
19+
ADMIN
20+
CUSTOMER
21+
}
22+
`);
23+
const document = parse(/* GraphQL */ `
24+
query User($id: ID!) {
25+
user(id: $id) {
26+
id
27+
name
28+
role
29+
}
30+
}
31+
`);
32+
33+
const { content } = await plugin(schema, [{ document }], {});
34+
35+
expect(content).toMatchInlineSnapshot(`
36+
"export type UserQueryVariables = Exact<{
37+
id: Scalars['ID']['input'];
38+
}>;
39+
40+
41+
export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, role: UserRole } | null };
42+
"
43+
`);
44+
45+
validateTs(content, undefined, undefined, undefined, undefined, true);
46+
});
47+
});

0 commit comments

Comments
 (0)