Skip to content

Commit

Permalink
Enhance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flostadler committed Nov 15, 2024
1 parent 9c960bb commit e6bd66a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/cfn-custom-resource-mappings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Stack } from 'aws-cdk-lib';
import { mapToCustomResource } from '../src/custom-resource-mapping';
import * as aws from '@pulumi/aws-native';
import { MockSynth } from './mocks';
import { typeName } from '../src/naming';

jest.mock('@pulumi/aws-native', () => {
return {
Expand Down Expand Up @@ -111,9 +112,28 @@ describe('Custom Resource Mapping', () => {
}
} as unknown as Stack;

// WHEN
// WHEN/THEN
expect(() => {
mapToCustomResource(logicalId, cfnType, cfnProps, {}, stack);
}).toThrow('Synthesizer of stack my-stack does not support custom resources. It must inherit from PulumiSynthesizerBase.');
});

test('Not a CustomResource', () => {
// GIVEN
const cfnType = 'AWS::S3::Bucket';
const logicalId = 'My-resource';


const stack = {
synthesizer: new MockSynth("bucket", "prefix/"),
node: {
id: 'my-stack',
}
} as unknown as Stack;

// WHEN
const returnValue = mapToCustomResource(logicalId, cfnType, {}, {}, stack);
// THEN
expect(returnValue).not.toBeDefined();
});
});

0 comments on commit e6bd66a

Please sign in to comment.