-
Notifications
You must be signed in to change notification settings - Fork 816
/
transform-host.test.ts
39 lines (36 loc) · 1.6 KB
/
transform-host.test.ts
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
import { DefaultTransformHost } from '../transform-host';
import { GraphQLApi, TransformerAPIProps } from '../graphql-api';
import { App } from '@aws-cdk/core';
import { InlineTemplate } from '../cdk-compat/template-asset';
import { TransformerRootStack } from '../cdk-compat/root-stack';
describe('addResolver', () => {
const app = new App();
const stack = new TransformerRootStack(app, 'test-root-stack');
const transformHost = new DefaultTransformHost({ api: new GraphQLApi(stack, 'testId', { name: 'testApiName' }) });
it('generates resolver name with hash for non-alphanumeric type names', () => {
const cfnResolver = transformHost.addResolver(
'test_type',
'testField',
new InlineTemplate('testTemplate'),
new InlineTemplate('testTemplate'),
undefined,
undefined,
['testPipelineConfig'],
stack,
);
expect(cfnResolver.logicalId).toMatch('testtype4c79TestFieldResolver.LogicalID'); // have to use match instead of equals because the logicalId is a CDK token that has some non-deterministic stuff in it
});
it('generates resolver name with hash for non-alphanumeric field names', () => {
const cfnResolver = transformHost.addResolver(
'testType',
'test_field',
new InlineTemplate('testTemplate'),
new InlineTemplate('testTemplate'),
undefined,
undefined,
['testPipelineConfig'],
stack,
);
expect(cfnResolver.logicalId).toMatch('testTypeTestfield6a0fResolver.LogicalID'); // have to use match instead of equals because the logicalId is a CDK token that has some non-deterministic stuff in it
});
});