forked from martysweet/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yamlSchema.ts
38 lines (32 loc) · 1.41 KB
/
yamlSchema.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
import buildYamlSchema, * as yamlSchema from '../yamlSchema';
import yaml = require('js-yaml');
import assert = require('assert');
describe('yamlSchema', () => {
describe('buildYamlSchema', () => {
it('should build a yaml schema', () => {
assert(buildYamlSchema() instanceof yaml.Schema, 'yamlSchema didn\'t return a yaml schema');
})
});
describe('functionTag', () => {
it('should work on a Fn::Thing', () => {
assert.strictEqual(yamlSchema.functionTag('Fn::Name'), 'Name');
})
it('should work on a Thing', () => {
assert.strictEqual(yamlSchema.functionTag('Name'), 'Name');
})
});
describe('buildYamlType', () => {
it('should return a type that builds the JSON representation of the yaml tag', () => {
const type = yamlSchema.buildYamlType('Fn::Join', 'sequence');
const input = ['asdf', 'asdf'];
const representation = type.construct(input);
assert.deepStrictEqual(representation, {'Fn::Join': ['asdf', 'asdf']});
});
it('should special-case Fn::GetAtt', () => {
const type = yamlSchema.buildYamlType('Fn::GetAtt', 'scalar');
const input = 'Resource.Attribute';
const representation = type.construct(input);
assert.deepStrictEqual(representation, {'Fn::GetAtt': ['Resource', 'Attribute']});
})
})
})