generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathResourceEdgeCaseTransformer.test.ts
More file actions
59 lines (46 loc) · 2.02 KB
/
ResourceEdgeCaseTransformer.test.ts
File metadata and controls
59 lines (46 loc) · 2.02 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { describe, it, expect } from 'vitest';
import { ResourceEdgeCaseTransformer } from '../../../../src/schema/transformers/ResourceEdgeCaseTransformer';
import { combinedSchemas } from '../../../utils/SchemaUtils';
describe('ResourceEdgeCaseTransformer', () => {
const schemas = combinedSchemas();
const transformer = new ResourceEdgeCaseTransformer();
it('should remove empty Description from AWS::WAFv2::IPSet', () => {
const schema = schemas.schemas.get('AWS::WAFv2::IPSet')!;
const resourceProperties = {
Name: 'test-ipset',
Description: '',
Scope: 'REGIONAL',
};
transformer.transform(resourceProperties, schema);
expect(resourceProperties.Description).toBeUndefined();
});
it('should remove whitespace-only Description from AWS::WAFv2::IPSet', () => {
const schema = schemas.schemas.get('AWS::WAFv2::IPSet')!;
const resourceProperties = {
Name: 'test-ipset',
Description: ' ',
Scope: 'REGIONAL',
};
transformer.transform(resourceProperties, schema);
expect(resourceProperties.Description).toBeUndefined();
});
it('should not modify valid Description with leading/trailing whitespace in AWS::WAFv2::IPSet', () => {
const schema = schemas.schemas.get('AWS::WAFv2::IPSet')!;
const resourceProperties = {
Name: 'test-ipset',
Description: ' Valid description ',
Scope: 'REGIONAL',
};
transformer.transform(resourceProperties, schema);
expect(resourceProperties.Description).toBe(' Valid description ');
});
it('should not modify resources without edge case handlers', () => {
const schema = schemas.schemas.get('AWS::S3::Bucket')!;
const resourceProperties = {
BucketName: 'test-bucket',
Description: '',
};
transformer.transform(resourceProperties, schema);
expect(resourceProperties.Description).toBe('');
});
});