-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.test.ts
More file actions
45 lines (34 loc) · 1.22 KB
/
plugin.test.ts
File metadata and controls
45 lines (34 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Types } from '@graphql-codegen/plugin-helpers'
import { plugin } from '../src'
import { loadDocuments } from '@graphql-tools/load'
test('Plugin generated wrapped types for provided documents with correct decorator', async () => {
// Schema is not used for index generation
const schema = undefined as any
// Generate test documents
const fragments = await loadDocuments(`
query ToBeIgnored {
TestType {
...IgnoreThisOne
}
}
fragment IgnoreThisOne on TestType {
id
}
fragment Webhook1 on TestType @generate1 {
id
name
}
fragment Webhook2 on TestType @generate2 {
id
}
`, {} as any)
// output configuration 1
const output1 = plugin(schema, fragments, { fragmentRegistryDirective: 'generate1', omitOperationSuffix: false })
expect(output1).toMatchSnapshot()
// output configuration 2
const output2 = plugin(schema, fragments, { fragmentRegistryDirective: 'generate2', omitOperationSuffix: true, fragmentRegistryName: 'WebhookMap' })
expect(output2).toMatchSnapshot()
// output configuration 3
const output3 = plugin(schema, fragments, {})
expect(output3).toMatchSnapshot()
})