diff --git a/packages/@aws-cdk/core/test/annotations.test.ts b/packages/@aws-cdk/core/test/annotations.test.ts index 0770f0ac3f07e..4ee07abdabf84 100644 --- a/packages/@aws-cdk/core/test/annotations.test.ts +++ b/packages/@aws-cdk/core/test/annotations.test.ts @@ -8,7 +8,6 @@ const restore = process.env.CDK_BLOCK_DEPRECATIONS; describe('annotations', () => { afterEach(() => { process.env.CDK_BLOCK_DEPRECATIONS = restore; // restore to the original value - }); test('addDeprecation() annotates the usage of a deprecated API', () => { @@ -28,7 +27,6 @@ describe('annotations', () => { message: 'The API @aws-cdk/core.Construct.node is deprecated: use @aws-Construct.construct instead. This API will be removed in the next major release', }, ]); - }); test('deduplicated per node based on "api"', () => { @@ -64,7 +62,6 @@ describe('annotations', () => { message: 'The API @aws-cdk/core.Construct.node is deprecated: use @aws-Construct.construct instead. This API will be removed in the next major release', }, ]); - }); test('CDK_BLOCK_DEPRECATIONS will throw if a deprecated API is used', () => { @@ -76,7 +73,6 @@ describe('annotations', () => { // THEN process.env.CDK_BLOCK_DEPRECATIONS = '1'; expect(() => Annotations.of(c1).addDeprecation('foo', 'bar')).toThrow(/MyStack\/Hello: The API foo is deprecated: bar\. This API will be removed in the next major release/); - }); }); diff --git a/packages/@aws-cdk/core/test/app.test.ts b/packages/@aws-cdk/core/test/app.test.ts index c7c6593eb0974..0cf612d690f1a 100644 --- a/packages/@aws-cdk/core/test/app.test.ts +++ b/packages/@aws-cdk/core/test/app.test.ts @@ -99,8 +99,6 @@ describe('app', () => { '/stack2/s1c2/r2': [{ type: 'aws:cdk:logicalId', data: 's1c2r25F685FFF' }], }); - - }); test('context can be passed through CDK_CONTEXT', () => { @@ -111,7 +109,6 @@ describe('app', () => { const prog = new App(); expect(prog.node.tryGetContext('key1')).toEqual('val1'); expect(prog.node.tryGetContext('key2')).toEqual('val2'); - }); test('context passed through CDK_CONTEXT has precedence', () => { @@ -127,7 +124,6 @@ describe('app', () => { }); expect(prog.node.tryGetContext('key1')).toEqual('val1'); expect(prog.node.tryGetContext('key2')).toEqual('val2'); - }); test('context from the command line can be used when creating the stack', () => { @@ -152,7 +148,6 @@ describe('app', () => { }, }, }); - }); test('setContext(k,v) can be used to set context programmatically', () => { @@ -162,18 +157,15 @@ describe('app', () => { }, }); expect(prog.node.tryGetContext('foo')).toEqual('bar'); - }); test('setContext(k,v) cannot be called after stacks have been added because stacks may use the context', () => { const prog = new App(); new Stack(prog, 's1'); expect(() => prog.node.setContext('foo', 'bar')).toThrow(); - }); test('app.synth() performs validation first and if there are errors, it returns the errors', () => { - class Child extends Construct { constructor(scope: Construct, id: string) { super(scope, id); @@ -183,7 +175,6 @@ describe('app', () => { } class Parent extends Stack { - } const app = new App(); @@ -193,8 +184,6 @@ describe('app', () => { new Child(parent, 'C2'); expect(() => app.synth()).toThrow(/Validation failed with the following errors/); - - }); test('app.synthesizeStack(stack) will return a list of missing contextual information', () => { @@ -248,8 +237,6 @@ describe('app', () => { }, }, ]); - - }); /** @@ -264,7 +251,6 @@ describe('app', () => { }); expect(assembly.runtime).toEqual({ libraries: {} }); - }); test('deep stack is shown and synthesized properly', () => { @@ -288,8 +274,6 @@ describe('app', () => { template: { Resources: { Res: { Type: 'CDK::BottomStack::Resource' } } }, }, ]); - - }); test('stacks are written to the assembly file in a topological order', () => { @@ -314,8 +298,6 @@ describe('app', () => { expect(artifactsIds.indexOf('StackA')).toBeLessThan(artifactsIds.indexOf('StackC')); expect(artifactsIds.indexOf('StackB')).toBeLessThan(artifactsIds.indexOf('StackC')); expect(artifactsIds.indexOf('StackC')).toBeLessThan(artifactsIds.indexOf('StackD')); - - }); test('application support any type in context', () => { @@ -330,8 +312,6 @@ describe('app', () => { expect(app.node.tryGetContext('isString')).toEqual('string'); expect(app.node.tryGetContext('isNumber')).toEqual(10); expect(app.node.tryGetContext('isObject')).toEqual({ isString: 'string', isNumber: 10 }); - - }); }); diff --git a/packages/@aws-cdk/core/test/arn.test.ts b/packages/@aws-cdk/core/test/arn.test.ts index 6da31f11f9b22..470051fb0db65 100644 --- a/packages/@aws-cdk/core/test/arn.test.ts +++ b/packages/@aws-cdk/core/test/arn.test.ts @@ -17,7 +17,6 @@ describe('arn', () => { expect(stack.resolve(arn)).toEqual( stack.resolve(`arn:${pseudo.partition}:sqs:${pseudo.region}:${pseudo.accountId}:myqueuename`)); - }); test('cannot rely on defaults when stack not known', () => { @@ -42,7 +41,6 @@ describe('arn', () => { expect(stack.resolve(arn)).toEqual( 'arn:aws-cn:dynamodb:us-east-1:123456789012:table/mytable/stream/label'); - }); test('allow empty string in components', () => { @@ -58,8 +56,6 @@ describe('arn', () => { expect(stack.resolve(arn)).toEqual( 'arn:aws-cn:s3:::my-bucket'); - - }); testDeprecated('resourcePathSep can be set to ":" instead of the default "/"', () => { @@ -76,7 +72,6 @@ describe('arn', () => { expect(stack.resolve(arn)).toEqual( stack.resolve(`arn:${pseudo.partition}:codedeploy:${pseudo.region}:${pseudo.accountId}:application:WordPress_App`)); - }); testDeprecated('resourcePathSep can be set to "" instead of the default "/"', () => { @@ -93,7 +88,6 @@ describe('arn', () => { expect(stack.resolve(arn)).toEqual( stack.resolve(`arn:${pseudo.partition}:ssm:${pseudo.region}:${pseudo.accountId}:parameter/parameter-name`)); - }); test('fails if resourcePathSep is neither ":" nor "/"', () => { @@ -104,7 +98,6 @@ describe('arn', () => { resource: 'bar', sep: 'x', })).toThrow(); - }); describeDeprecated('Arn.parse(s)', () => { @@ -119,19 +112,16 @@ describe('arn', () => { test('if the ARN doesnt have enough components', () => { const stack = new Stack(); expect(() => stack.parseArn('arn:is:too:short')).toThrow(/The `resource` component \(6th component\) of an ARN is required/); - }); test('if "service" is not specified', () => { const stack = new Stack(); expect(() => stack.parseArn('arn:aws::4:5:6')).toThrow(/The `service` component \(3rd component\) of an ARN is required/); - }); test('if "resource" is not specified', () => { const stack = new Stack(); expect(() => stack.parseArn('arn:aws:service:::')).toThrow(/The `resource` component \(6th component\) of an ARN is required/); - }); }); @@ -236,8 +226,6 @@ describe('arn', () => { const evaluatedArnComponents = evaluateCFN(cfnArnComponents, { TheArn: arn }); expect(evaluatedArnComponents).toEqual(parsedComponents); } - - }); test('a Token with : separator', () => { @@ -252,8 +240,6 @@ describe('arn', () => { expect(stack.resolve(parsed.resource)).toEqual({ 'Fn::Select': [5, { 'Fn::Split': [':', theToken] }] }); expect(stack.resolve(parsed.resourceName)).toEqual({ 'Fn::Select': [6, { 'Fn::Split': [':', theToken] }] }); expect(parsed.sep).toEqual(':'); - - }); test('a Token with / separator', () => { @@ -267,8 +253,6 @@ describe('arn', () => { expect(stack.resolve(parsed.resource)).toEqual({ 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', theToken] }] }] }] }); // eslint-disable-next-line max-len expect(stack.resolve(parsed.resourceName)).toEqual({ 'Fn::Select': [1, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', theToken] }] }] }] }); - - }); test('extracting resource name from a complex ARN', () => { @@ -283,8 +267,6 @@ describe('arn', () => { expect(evaluateCFN(stack.resolve(parsed), { SomeParameter: 'arn:aws:iam::111111111111:role/path/to/role/name', })).toEqual('path/to/role/name'); - - }); test('extractResourceName validates resource type if possible', () => { @@ -292,8 +274,6 @@ describe('arn', () => { expect(() => { Arn.extractResourceName('arn:aws:iam::111111111111:banana/rama', 'role'); }).toThrow(/Expected resource type/); - - }); test('returns empty string ARN components', () => { @@ -311,7 +291,6 @@ describe('arn', () => { }; expect(stack.parseArn(arn)).toEqual(expected); - }); }); @@ -340,8 +319,6 @@ describe('arn', () => { }, }, }); - - }); testDeprecated('parse other fields if only some are tokens', () => { @@ -359,7 +336,5 @@ describe('arn', () => { expect(stack.resolve(parsed.resource)).toEqual('role'); expect(stack.resolve(parsed.resourceName)).toEqual('S3Access'); expect(parsed.sep).toEqual('/'); - - }); }); diff --git a/packages/@aws-cdk/core/test/aspect.test.ts b/packages/@aws-cdk/core/test/aspect.test.ts index d8f79126df035..b431c0272a579 100644 --- a/packages/@aws-cdk/core/test/aspect.test.ts +++ b/packages/@aws-cdk/core/test/aspect.test.ts @@ -33,7 +33,6 @@ describe('aspect', () => { expect(root.visitCounter).toEqual(1); app.synth(); expect(root.visitCounter).toEqual(1); - }); test('Warn if an Aspect is added via another Aspect', () => { @@ -54,7 +53,6 @@ describe('aspect', () => { expect(root.node.metadata[0].data).toEqual('We detected an Aspect was added via another Aspect, and will not be applied'); // warning is not added to child construct expect(child.node.metadata.length).toEqual(0); - }); test('Do not warn if an Aspect is added directly (not by another aspect)', () => { @@ -70,7 +68,5 @@ describe('aspect', () => { // no warning is added expect(root.node.metadata.length).toEqual(1); expect(child.node.metadata.length).toEqual(1); - }); - }); diff --git a/packages/@aws-cdk/core/test/assets.test.ts b/packages/@aws-cdk/core/test/assets.test.ts index 737f5f0aabdad..dedfb1a05d3bc 100644 --- a/packages/@aws-cdk/core/test/assets.test.ts +++ b/packages/@aws-cdk/core/test/assets.test.ts @@ -49,8 +49,6 @@ describe('assets', () => { }, }, }); - - }); test('addFileAsset correctly sets object urls', () => { @@ -69,8 +67,6 @@ describe('assets', () => { assetLocation.s3ObjectUrl.replace(expectedS3UrlPrefix, '')).toEqual( assetLocation.httpUrl.replace(expectedHttpUrlPrefix, ''), ); - - }); test('addDockerImageAsset correctly sets metadata', () => { diff --git a/packages/@aws-cdk/core/test/bundling.test.ts b/packages/@aws-cdk/core/test/bundling.test.ts index 65b4f6247ba81..0752d346466da 100644 --- a/packages/@aws-cdk/core/test/bundling.test.ts +++ b/packages/@aws-cdk/core/test/bundling.test.ts @@ -43,7 +43,6 @@ describe('bundling', () => { 'alpine', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); test('bundling with image from asset', () => { @@ -85,7 +84,6 @@ describe('bundling', () => { 'run', '--rm', tag, ])).toEqual(true); - }); test('bundling with image from asset with platform', () => { @@ -122,7 +120,6 @@ describe('bundling', () => { 'run', '--rm', tag, ])).toEqual(true); - }); test('bundling with image from asset with target stage', () => { @@ -176,7 +173,6 @@ describe('bundling', () => { const image = DockerImage.fromRegistry('alpine'); expect(() => image.run()).toThrow(/UnknownError/); - }); test('throws if status is not 0', () => { @@ -191,14 +187,12 @@ describe('bundling', () => { const image = DockerImage.fromRegistry('alpine'); expect(() => image.run()).toThrow(/\[Status -1\]/); - }); test('BundlerDockerImage json is the bundler image name by default', () => { const image = DockerImage.fromRegistry('alpine'); expect(image.toJSON()).toEqual('alpine'); - }); test('BundlerDockerImage json is the bundler image if building an image', () => { @@ -223,7 +217,6 @@ describe('bundling', () => { expect(image.image).toEqual(`cdk-${tagHash}`); expect(image.toJSON()).toEqual(imageHash); expect(fingerprintStub.calledWith('docker-path', sinon.match({ extraHash: JSON.stringify({}) }))).toEqual(true); - }); test('custom dockerfile is passed through to docker exec', () => { @@ -244,8 +237,6 @@ describe('bundling', () => { expect(spawnSyncStub.calledOnce).toEqual(true); const expected = path.join(imagePath, 'my-dockerfile'); expect(new RegExp(`-f ${expected}`).test(spawnSyncStub.firstCall.args[1]?.join(' ') ?? '')).toEqual(true); - - }); test('fromAsset', () => { @@ -264,7 +255,6 @@ describe('bundling', () => { }); expect(image).toBeDefined(); expect(image.image).toBeDefined(); - }); test('custom entrypoint is passed through to docker exec', () => { @@ -303,7 +293,6 @@ describe('bundling', () => { '--cool-entrypoint-arg', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); test('cp utility copies from an image', () => { @@ -325,8 +314,6 @@ describe('bundling', () => { expect(spawnSyncStub.calledWith(sinon.match.any, ['create', 'alpine'], sinon.match.any)).toEqual(true); expect(spawnSyncStub.calledWith(sinon.match.any, ['cp', `${containerId}:/foo/bar`, '/baz'], sinon.match.any)).toEqual(true); expect(spawnSyncStub.calledWith(sinon.match.any, ['rm', '-v', containerId])).toEqual(true); - - }); test('cp utility cleans up after itself', () => { @@ -358,7 +345,6 @@ describe('bundling', () => { // THEN expect(spawnSyncStub.calledWith(sinon.match.any, ['rm', '-v', containerId])).toEqual(true); - }); test('cp utility copies to a temp dir of outputPath is omitted', () => { @@ -378,8 +364,6 @@ describe('bundling', () => { // THEN expect(/cdk-docker-cp-/.test(tempPath)).toEqual(true); - - }); test('adding user provided security-opt', () => { @@ -419,7 +403,6 @@ describe('bundling', () => { 'alpine', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); test('ensure selinux docker mount', () => { @@ -461,7 +444,6 @@ describe('bundling', () => { 'alpine', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); test('ensure selinux docker mount on linux with selinux disabled', () => { @@ -503,8 +485,8 @@ describe('bundling', () => { 'alpine', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); + test('ensure no selinux docker mount if selinuxenabled isn\'t an available command', () => { // GIVEN sinon.stub(process, 'platform').value('linux'); @@ -544,6 +526,5 @@ describe('bundling', () => { 'alpine', 'cool', 'command', ], { stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true); - }); }); diff --git a/packages/@aws-cdk/core/test/cfn-json.test.ts b/packages/@aws-cdk/core/test/cfn-json.test.ts index ff072b9c2c6b1..0a4a988957300 100644 --- a/packages/@aws-cdk/core/test/cfn-json.test.ts +++ b/packages/@aws-cdk/core/test/cfn-json.test.ts @@ -26,8 +26,6 @@ describe('cfn json', () => { // output is basically an Fn::GetAtt expect(stack.resolve(json)).toEqual({ 'Fn::GetAtt': ['MyCfnJson248769BB', 'Value'] }); - - }); test('tokens and intrinsics can be used freely in keys or values', () => { @@ -52,7 +50,6 @@ describe('cfn json', () => { expect(template.Resources.MyCfnJson248769BB.Properties.Value).toEqual({ 'Fn::Join': ['', ['{"', { Ref: 'Other' }, '":1234,"world":{"bar":"this is a I am lazy"}}']], }); - }); test('JSON.stringify() will return the CFN-stringified value to avoid circular references', () => { @@ -73,8 +70,6 @@ describe('cfn json', () => { expect(stack.resolve(str)).toEqual({ 'Fn::Join': ['', ['"{"ref=', { Ref: 'MyResource' }, '":"this is a I am lazy"}"']], }); - - }); test('resource provider simply parses json and reflects back as an attribute', async () => { @@ -86,6 +81,5 @@ describe('cfn json', () => { }, } as any); expect(input).toEqual(response.Data.Value); - }); }); diff --git a/packages/@aws-cdk/core/test/cfn-parameter.test.ts b/packages/@aws-cdk/core/test/cfn-parameter.test.ts index a93b83f973522..5c4c4c736cb29 100644 --- a/packages/@aws-cdk/core/test/cfn-parameter.test.ts +++ b/packages/@aws-cdk/core/test/cfn-parameter.test.ts @@ -14,8 +14,6 @@ describe('cfn parameter', () => { // THEN expect(stack.resolve(numVal)).toEqual({ Ref: 'numberParam' }); expect(stack.resolve(strVal)).toEqual({ Ref: 'stringParam' }); - - }); test('valueAsString fails for unsupported types', () => { @@ -25,7 +23,5 @@ describe('cfn parameter', () => { // WHEN - THEN expect(() => listParam.valueAsList).toThrow(/Parameter type \(List\)/); - - }); }); diff --git a/packages/@aws-cdk/core/test/cfn-resource.test.ts b/packages/@aws-cdk/core/test/cfn-resource.test.ts index 7fae8197bcf65..5bd63aee020d8 100644 --- a/packages/@aws-cdk/core/test/cfn-resource.test.ts +++ b/packages/@aws-cdk/core/test/cfn-resource.test.ts @@ -20,8 +20,6 @@ describe('cfn resource', () => { }, }); expect(called).toEqual(true); - - }); test('renders "Properties" for a resource that has only properties set to "false"', () => { @@ -42,8 +40,6 @@ describe('cfn resource', () => { }, }, }); - - }); }); @@ -64,8 +60,6 @@ describe('cfn resource', () => { UpdateReplacePolicy: 'Retain', }, }); - - }); test('can switch off updating Update policy', () => { @@ -86,8 +80,6 @@ describe('cfn resource', () => { DeletionPolicy: 'Retain', }, }); - - }); test('can add metadata', () => { @@ -108,8 +100,6 @@ describe('cfn resource', () => { }, }, }); - - }); test('can read metadata', () => { @@ -121,8 +111,6 @@ describe('cfn resource', () => { // THEN expect(resource.getMetadata('Beep')).toEqual('Boop'); - - }); test('subclasses can override "shouldSynthesize" to lazy-determine if the resource should be included', () => { @@ -151,8 +139,6 @@ describe('cfn resource', () => { // No DependsOn! }, }); - - }); test('CfnResource cannot be created outside Stack', () => { @@ -162,8 +148,6 @@ describe('cfn resource', () => { type: 'Some::Resource', }); }).toThrow(/should be created in the scope of a Stack, but no Stack found/); - - }); /** @@ -178,7 +162,5 @@ describe('cfn resource', () => { type: 'Some::Resource', }); }).toThrow(/should be created in the scope of a Stack, but no Stack found/); - - }); }); diff --git a/packages/@aws-cdk/core/test/cloudformation-json.test.ts b/packages/@aws-cdk/core/test/cloudformation-json.test.ts index 938f12349afcb..dda7ae6640b93 100644 --- a/packages/@aws-cdk/core/test/cloudformation-json.test.ts +++ b/packages/@aws-cdk/core/test/cloudformation-json.test.ts @@ -123,7 +123,6 @@ describe('tokens that return literals', () => { }); }); - test('tokens in strings survive additional TokenJSON.stringification()', () => { // GIVEN for (const token of tokensThatResolveTo('pong!')) { @@ -160,7 +159,6 @@ describe('tokens that return literals', () => { // THEN expect(evaluateCFN(resolved)).toEqual('{"information":"Did you know that Fido says: \\"woof\\""}'); }); - }); describe('tokens returning CloudFormation intrinsics', () => { @@ -406,7 +404,6 @@ test('JSON strings nested inside JSON strings have correct quoting', () => { expect(JSON.parse(JSON.parse(evaluated).payload).message).toEqual('I am in account "1234"'); }); - /** * Return two Tokens, one of which evaluates to a Token directly, one which evaluates to it lazily */ diff --git a/packages/@aws-cdk/core/test/condition.test.ts b/packages/@aws-cdk/core/test/condition.test.ts index 54b5a90fea515..72d5dd2d17749 100644 --- a/packages/@aws-cdk/core/test/condition.test.ts +++ b/packages/@aws-cdk/core/test/condition.test.ts @@ -31,8 +31,6 @@ describe('condition', () => { }, }, }); - - }); test('condition expressions can be embedded as strings', () => { @@ -60,6 +58,5 @@ describe('condition', () => { }, }, }); - }); }); diff --git a/packages/@aws-cdk/core/test/construct.test.ts b/packages/@aws-cdk/core/test/construct.test.ts index 37cd35850bfa6..3e598ae8013a8 100644 --- a/packages/@aws-cdk/core/test/construct.test.ts +++ b/packages/@aws-cdk/core/test/construct.test.ts @@ -13,13 +13,11 @@ describe('construct', () => { expect(root.node.id).toEqual(''); expect(root.node.scope).toBeUndefined(); expect(root.node.children.length).toEqual(0); - }); test('constructs cannot be created with an empty name unless they are root', () => { const root = new Root(); expect(() => new Construct(root, '')).toThrow(); - }); test('construct.name returns the name of the construct', () => { @@ -31,8 +29,6 @@ describe('construct', () => { expect(t.child1_2.node.id).toEqual('Child12'); expect(t.child1_1_1.node.id).toEqual('Child111'); expect(t.child2_1.node.id).toEqual('Child21'); - - }); test('construct id can use any character except the path separator', () => { @@ -49,20 +45,17 @@ describe('construct', () => { new Construct(root, 'in-Valid' ); new Construct(root, 'in\\Valid' ); new Construct(root, 'in.Valid' ); - }); test('if construct id contains path seperators, they will be replaced by double-dash', () => { const root = new Root(); const c = new Construct(root, 'Boom/Boom/Bam'); expect(c.node.id).toEqual('Boom--Boom--Bam'); - }); test('if "undefined" is forcefully used as an "id", it will be treated as an empty string', () => { const c = new Construct(undefined as any, undefined as any); expect(c.node.id).toEqual(''); - }); testDeprecated('construct.uniqueId returns a tree-unique alphanumeric id of this construct', () => { @@ -77,14 +70,12 @@ describe('construct', () => { expect(c2.node.path).toEqual('This is the first child/My construct'); expect(Names.uniqueId(c1)).toEqual('ThisisthefirstchildSecondlevelMyconstruct202131E0'); expect(Names.uniqueId(c2)).toEqual('ThisisthefirstchildMyconstruct8C288DF9'); - }); testDeprecated('cannot calculate uniqueId if the construct path is ["Default"]', () => { const root = new Root(); const c = new Construct(root, 'Default'); expect(() => Names.uniqueId(c)).toThrow(/Unable to calculate a unique id for an empty set of components/); - }); test('construct.getChildren() returns an array of all children', () => { @@ -93,7 +84,6 @@ describe('construct', () => { new Construct(root, 'Child2'); expect(child.node.children.length).toEqual(0); expect(root.node.children.length).toEqual(2); - }); test('construct.findChild(name) can be used to retrieve a child from a parent', () => { @@ -101,7 +91,6 @@ describe('construct', () => { const child = new Construct(root, 'Contruct'); expect(root.node.tryFindChild(child.node.id)).toEqual(child); expect(root.node.tryFindChild('NotFound')).toBeUndefined(); - }); test('construct.getChild(name) can be used to retrieve a child from a parent', () => { @@ -111,7 +100,6 @@ describe('construct', () => { expect(() => { root.node.findChild('NotFound'); }).toThrow(); - }); test('can remove children from the tree using tryRemoveChild()', () => { @@ -125,7 +113,6 @@ describe('construct', () => { expect(undefined).toEqual(root.node.tryFindChild(child.node.id)); expect(childrenBeforeAdding).toEqual(root.node.children.length); - }); test('construct.toString() and construct.toTreeString() can be used for diagnostics', () => { @@ -135,7 +122,6 @@ describe('construct', () => { expect(t.child1_1_1.toString()).toEqual('HighChild/Child1/Child11/Child111'); expect(t.child2.toString()).toEqual('HighChild/Child2'); expect(toTreeString(t.root)).toEqual('Root\n Construct [HighChild]\n Construct [Child1]\n Construct [Child11]\n Construct [Child111]\n Construct [Child12]\n Construct [Child2]\n Construct [Child21]\n'); - }); test('construct.getContext(key) can be used to read a value from context defined at the root level', () => { @@ -147,7 +133,6 @@ describe('construct', () => { const t = createTree(context); expect(t.child1_2.node.tryGetContext('ctx1')).toEqual(12); expect(t.child1_1_1.node.tryGetContext('ctx2')).toEqual('hello'); - }); // eslint-disable-next-line max-len @@ -182,15 +167,12 @@ describe('construct', () => { expect(child3.node.tryGetContext('c2')).toEqual('child1'); expect(child3.node.tryGetContext('c3')).toEqual('child1'); expect(child3.node.tryGetContext('c4')).toEqual('child3'); - - }); test('construct.setContext(key, value) can only be called before adding any children', () => { const root = new Root(); new Construct(root, 'child1'); expect(() => root.node.setContext('k', 'v')); - }); test('construct.pathParts returns an array of strings of all names from root to node', () => { @@ -198,14 +180,12 @@ describe('construct', () => { expect(tree.root.node.path).toEqual(''); expect(tree.child1_1_1.node.path).toEqual('HighChild/Child1/Child11/Child111'); expect(tree.child2.node.path).toEqual('HighChild/Child2'); - }); test('if a root construct has a name, it should be included in the path', () => { const tree = createTree({}); expect(tree.root.node.path).toEqual(''); expect(tree.child1_1_1.node.path).toEqual('HighChild/Child1/Child11/Child111'); - }); test('construct can not be created with the name of a sibling', () => { @@ -227,8 +207,6 @@ describe('construct', () => { expect(() => { new Construct(c0, 'SameName'); }).toThrow(/There is already a Construct with name 'SameName' in Construct \[c0\]/); - - }); test('addMetadata(type, data) can be used to attach metadata to constructs FIND_ME', () => { @@ -247,7 +225,6 @@ describe('construct', () => { expect(con.node.metadata[1].data).toEqual(103); expect(con.node.metadata[2].data).toEqual([123, 456]); expect(con.node.metadata[0].trace && con.node.metadata[0].trace[1].indexOf('FIND_ME')).toEqual(-1); - }); test('addMetadata(type, undefined/null) is ignored', () => { @@ -266,7 +243,6 @@ describe('construct', () => { expect(exists('True')).toBeDefined(); expect(exists('False')).toBeDefined(); expect(exists('Empty')).toBeDefined(); - }); test('addWarning(message) can be used to add a "WARNING" message entry to the construct', () => { @@ -279,7 +255,6 @@ describe('construct', () => { expect(con.node.metadata[0].type).toEqual(cxschema.ArtifactMetadataEntryType.WARN); expect(con.node.metadata[0].data).toEqual('This construct is deprecated, use the other one instead'); expect(con.node.metadata[0].trace && con.node.metadata[0].trace.length > 0).toEqual(true); - }); test('addError(message) can be used to add a "ERROR" message entry to the construct', () => { @@ -292,7 +267,6 @@ describe('construct', () => { expect(con.node.metadata[0].type).toEqual(cxschema.ArtifactMetadataEntryType.ERROR); expect(con.node.metadata[0].data).toEqual('Stop!'); expect(con.node.metadata[0].trace && con.node.metadata[0].trace.length > 0).toEqual(true); - }); test('addInfo(message) can be used to add an "INFO" message entry to the construct', () => { @@ -305,7 +279,6 @@ describe('construct', () => { expect(con.node.metadata[0].type).toEqual(cxschema.ArtifactMetadataEntryType.INFO); expect(con.node.metadata[0].data).toEqual('Hey there, how do you do?'); expect(con.node.metadata[0].trace && con.node.metadata[0].trace.length > 0).toEqual(true); - }); test('multiple children of the same type, with explicit names are welcome', () => { @@ -315,12 +288,10 @@ describe('construct', () => { new MyBeautifulConstruct(root, 'mbc3'); new MyBeautifulConstruct(root, 'mbc4'); expect(root.node.children.length).toBeGreaterThanOrEqual(4); - }); // eslint-disable-next-line max-len test('construct.validate() can be implemented to perform validation, ConstructNode.validate(construct.node) will return all errors from the subtree (DFS)', () => { - class MyConstruct extends Construct { constructor(scope: Construct, id: string) { super(scope, id); @@ -375,12 +346,9 @@ describe('construct', () => { { path: 'TheirConstruct', message: 'their-error' }, { path: 'TheirConstruct/YourConstruct', message: 'your-error1' }, ]); - - }); test('construct.lock() protects against adding children anywhere under this construct (direct or indirect)', () => { - class LockableConstruct extends Construct { public lockMe() { this.node.lock(); @@ -402,7 +370,6 @@ describe('construct', () => { expect(() => new Construct(c0a, 'fail1')).toThrow(/Cannot add children to "c0a" during synthesis/); expect(() => new Construct(c1a, 'fail2')).toThrow(/Cannot add children to "c0a\/c1a" during synthesis/); expect(() => new Construct(c1b, 'fail3')).toThrow(/Cannot add children to "c0a\/c1b" during synthesis/); - }); test('findAll returns a list of all children in either DFS or BFS', () => { @@ -417,13 +384,11 @@ describe('construct', () => { expect(c1.node.findAll().map(x => x.node.id)).toEqual(c1.node.findAll(ConstructOrder.PREORDER).map(x => x.node.id)); // default is PreOrder expect(c1.node.findAll(ConstructOrder.PREORDER).map(x => x.node.id)).toEqual(['1', '2', '4', '5', '3']); expect(c1.node.findAll(ConstructOrder.POSTORDER).map(x => x.node.id)).toEqual(['4', '5', '2', '3', '1']); - }); test('ancestors returns a list of parents up to root', () => { const { child1_1_1 } = createTree(); expect(child1_1_1.node.scopes.map(x => x.node.id)).toEqual(['', 'HighChild', 'Child1', 'Child11', 'Child111']); - }); test('"root" returns the root construct', () => { @@ -431,7 +396,6 @@ describe('construct', () => { expect(child1.node.root).toEqual(root); expect(child2.node.root).toEqual(root); expect(child1_1_1.node.root).toEqual(root); - }); describe('defaultChild', () => { @@ -442,8 +406,8 @@ describe('construct', () => { new Construct(root, 'child2'); expect(root.node.defaultChild).toEqual(defaultChild); - }); + test('returns the child with id "Default"', () => { const root = new Root(); new Construct(root, 'child1'); @@ -451,8 +415,8 @@ describe('construct', () => { new Construct(root, 'child2'); expect(root.node.defaultChild).toEqual(defaultChild); - }); + test('can override defaultChild', () => { const root = new Root(); new Construct(root, 'Resource'); @@ -460,16 +424,16 @@ describe('construct', () => { root.node.defaultChild = defaultChild; expect(root.node.defaultChild).toEqual(defaultChild); - }); + test('returns "undefined" if there is no default', () => { const root = new Root(); new Construct(root, 'child1'); new Construct(root, 'child2'); expect(root.node.defaultChild).toEqual(undefined); - }); + test('fails if there are both "Resource" and "Default"', () => { const root = new Root(); new Construct(root, 'child1'); @@ -479,8 +443,6 @@ describe('construct', () => { expect(() => root.node.defaultChild).toThrow( /Cannot determine default child for . There is both a child with id "Resource" and id "Default"/); - - }); }); }); diff --git a/packages/@aws-cdk/core/test/context.test.ts b/packages/@aws-cdk/core/test/context.test.ts index f04a658d3e1b7..46d9e66d35775 100644 --- a/packages/@aws-cdk/core/test/context.test.ts +++ b/packages/@aws-cdk/core/test/context.test.ts @@ -24,8 +24,6 @@ describe('context', () => { const azs = stack.availabilityZones; expect(azs).toEqual(['us-east-1a', 'us-east-1b']); - - }); test('AvailabilityZoneProvider will complain if not given a list', () => { @@ -40,8 +38,6 @@ describe('context', () => { expect( () => stack.availabilityZones, ).toThrow(); - - }); test('ContextProvider consistently generates a key', () => { @@ -82,7 +78,6 @@ describe('context', () => { igw: false, }, }); - }); test('Key generation can contain arbitrarily deep structures', () => { @@ -112,8 +107,6 @@ describe('context', () => { ], }, }); - - }); test('Keys with undefined values are not serialized', () => { @@ -139,8 +132,6 @@ describe('context', () => { p2: undefined, }, }); - - }); test('context provider errors are attached to tree', () => { @@ -167,8 +158,6 @@ describe('context', () => { // THEN const error = construct.node.metadata.find(m => m.type === 'aws:cdk:error'); expect(error && error.data).toEqual('I had a boo-boo'); - - }); test('can skip account/region from attach to context', () => { diff --git a/packages/@aws-cdk/core/test/cross-environment-token.test.ts b/packages/@aws-cdk/core/test/cross-environment-token.test.ts index 09ac68ff864d0..a84da4714ba41 100644 --- a/packages/@aws-cdk/core/test/cross-environment-token.test.ts +++ b/packages/@aws-cdk/core/test/cross-environment-token.test.ts @@ -48,8 +48,6 @@ describe('cross environment', () => { }, }, }); - - }); test('can reference a fixed physical name directly in a different account', () => { @@ -82,8 +80,6 @@ describe('cross environment', () => { }, }, }); - - }); test('can reference an ARN with an assigned physical name directly in a different account', () => { @@ -128,8 +124,6 @@ describe('cross environment', () => { }, }, }); - - }); test('can reference an assigned physical name directly in a different account', () => { @@ -162,8 +156,6 @@ describe('cross environment', () => { }, }, }); - - }); }); @@ -192,8 +184,6 @@ describe('cross environment', () => { // THEN expect(() => toCloudFormation(stack2)).toThrow( /Cannot use resource 'Stack1\/MyResource' in a cross-environment fashion/); - - }); test('cross environment when stack is a substack', () => { @@ -235,8 +225,6 @@ describe('cross environment', () => { }, }, }); - - }); }); diff --git a/packages/@aws-cdk/core/test/custom-resource.test.ts b/packages/@aws-cdk/core/test/custom-resource.test.ts index 6f35597864f1b..7e721235adef9 100644 --- a/packages/@aws-cdk/core/test/custom-resource.test.ts +++ b/packages/@aws-cdk/core/test/custom-resource.test.ts @@ -30,7 +30,6 @@ describe('custom resource', () => { }, }, }); - }); test('resource type can be specified', () => { @@ -56,7 +55,6 @@ describe('custom resource', () => { }, }, }); - }); test('removal policy', () => { @@ -82,7 +80,6 @@ describe('custom resource', () => { }, }, }); - }); test('resource type must begin with "Custom::"', () => { @@ -94,8 +91,6 @@ describe('custom resource', () => { resourceType: 'MyResourceType', serviceToken: 'FooBar', })).toThrow(/Custom resource type must begin with "Custom::"/); - - }); test('properties can be pascal-cased', () => { @@ -131,7 +126,6 @@ describe('custom resource', () => { }, }, }); - }); test('pascal-casing of props is disabled by default', () => { @@ -166,7 +160,5 @@ describe('custom resource', () => { }, }, }); - }); - }); diff --git a/packages/@aws-cdk/core/test/dynamic-reference.test.ts b/packages/@aws-cdk/core/test/dynamic-reference.test.ts index 894339d231d7b..406c34782e8c9 100644 --- a/packages/@aws-cdk/core/test/dynamic-reference.test.ts +++ b/packages/@aws-cdk/core/test/dynamic-reference.test.ts @@ -10,7 +10,5 @@ describe('dynamic reference', () => { // THEN expect(stack.resolve(ref)).toEqual('{{resolve:ssm:a:b:c}}'); - - }); }); diff --git a/packages/@aws-cdk/core/test/environment.test.ts b/packages/@aws-cdk/core/test/environment.test.ts index 01a122a825f77..9e851c7469bc3 100644 --- a/packages/@aws-cdk/core/test/environment.test.ts +++ b/packages/@aws-cdk/core/test/environment.test.ts @@ -21,8 +21,6 @@ describe('environment', () => { expect(stack2.resolve(stack2.account)).toEqual('only-account'); expect(stack2.resolve(stack2.region)).toEqual({ Ref: 'AWS::Region' }); - - }); describe('environment defaults', () => { @@ -41,8 +39,6 @@ describe('environment', () => { region: 'unknown-region', name: 'aws://unknown-account/unknown-region', }); - - }); test('only region is set', () => { @@ -60,8 +56,6 @@ describe('environment', () => { region: 'explicit-region', name: 'aws://unknown-account/explicit-region', }); - - }); test('both "region" and "account" are set', () => { @@ -84,8 +78,6 @@ describe('environment', () => { region: 'explicit-region', name: 'aws://explicit-account/explicit-region', }); - - }); test('token-account and token-region', () => { @@ -108,8 +100,6 @@ describe('environment', () => { region: 'unknown-region', name: 'aws://unknown-account/unknown-region', }); - - }); test('token-account explicit region', () => { @@ -132,8 +122,6 @@ describe('environment', () => { region: 'us-east-2', name: 'aws://unknown-account/us-east-2', }); - - }); }); }); diff --git a/packages/@aws-cdk/core/test/expiration.test.ts b/packages/@aws-cdk/core/test/expiration.test.ts index f1770994dfbea..2caf42af03cdf 100644 --- a/packages/@aws-cdk/core/test/expiration.test.ts +++ b/packages/@aws-cdk/core/test/expiration.test.ts @@ -4,7 +4,6 @@ describe('expiration', () => { test('from string', () => { const date = new Date('Sun, 26 Jan 2020 00:53:20 GMT'); expect(Expiration.fromString('Sun, 26 Jan 2020 00:53:20 GMT').date.getDate()).toEqual(date.getDate()); - }); test('at specified date', () => { @@ -12,37 +11,30 @@ describe('expiration', () => { expect(Expiration.atDate(new Date('Sun, 26 Jan 2020 00:53:20 GMT')).date.toUTCString()).toEqual('Sun, 26 Jan 2020 00:53:20 GMT'); expect(Expiration.atDate(new Date(1580000000000)).date.toUTCString()).toEqual('Sun, 26 Jan 2020 00:53:20 GMT'); expect(Expiration.atDate(new Date(date)).date.toUTCString()).toEqual('Sun, 26 Jan 2020 00:53:20 GMT'); - }); test('at time stamp', () => { expect(Expiration.atDate(new Date(1580000000000)).date.toUTCString()).toEqual('Sun, 26 Jan 2020 00:53:20 GMT'); - }); test('after', () => { expect(Math.abs(new Date(Expiration.after(Duration.minutes(10)).date.toUTCString()).getTime() - (Date.now() + 600000)) < 15000).toBeDefined(); - }); test('toEpoch returns correct value', () => { const date = new Date('Sun, 26 Jan 2020 00:53:20 GMT'); expect(Expiration.atDate(date).toEpoch()).toEqual(1580000000); - }); test('isBefore', () => { const expire = Expiration.after(Duration.days(2)); expect(expire.isBefore(Duration.days(1))).toEqual(false); expect(expire.isBefore(Duration.days(3))).toEqual(true); - }); test('isAfter', () => { const expire = Expiration.after(Duration.days(2)); expect(expire.isAfter(Duration.days(1))).toEqual(true); expect(expire.isAfter(Duration.days(3))).toEqual(false); - }); - }); diff --git a/packages/@aws-cdk/core/test/feature-flags.test.ts b/packages/@aws-cdk/core/test/feature-flags.test.ts index cdffe64e04d2f..a65490afc375c 100644 --- a/packages/@aws-cdk/core/test/feature-flags.test.ts +++ b/packages/@aws-cdk/core/test/feature-flags.test.ts @@ -9,7 +9,6 @@ describe('feature flags', () => { const actual = FeatureFlags.of(stack).isEnabled(cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT); expect(actual).toEqual(true); - }); test('falls back to the default', () => { @@ -17,14 +16,12 @@ describe('feature flags', () => { expect(FeatureFlags.of(stack).isEnabled(cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT)).toEqual( cxapi.futureFlagDefault(cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT)); - }); test('invalid flag', () => { const stack = new Stack(); expect(FeatureFlags.of(stack).isEnabled('non-existent-flag')).toEqual(false); - }); }); }); diff --git a/packages/@aws-cdk/core/test/fn.test.ts b/packages/@aws-cdk/core/test/fn.test.ts index 7ebdcc6578f75..2e213020b4ee3 100644 --- a/packages/@aws-cdk/core/test/fn.test.ts +++ b/packages/@aws-cdk/core/test/fn.test.ts @@ -14,7 +14,6 @@ function asyncTest(cb: () => Promise): () => void { expect(() => { if (error) { throw error; } }).not.toThrow(); - } }; } @@ -47,14 +46,14 @@ describe('fn', () => { test('Fn.split', () => { expect(Fn.split(':', 'hello:world:yeah')).toEqual(['hello', 'world', 'yeah']); - }); }); + describe('FnParseDomainName', () => { test('parse domain name from resolved url', () => { expect(Fn.parseDomainName('https://test.com/')).toEqual('test.com'); - }); + test('parse domain name on token', () => { const stack = new Stack(); const url = Fn.join('//', [ @@ -65,14 +64,14 @@ describe('fn', () => { ]), ]); expect(Fn.parseDomainName(stack.resolve(url))).toEqual('test.com'); - }); }); + describe('FnJoin', () => { test('rejects empty list of arguments to join', () => { expect(() => Fn.join('.', [])).toThrow(); - }); + test('collapse nested FnJoins even if they contain tokens', () => { const stack = new Stack(); @@ -90,9 +89,8 @@ describe('fn', () => { 'cd', ]], }); - - }); + test('resolves to the value if only one value is joined', asyncTest(async () => { const stack = new Stack(); fc.assert( @@ -103,6 +101,7 @@ describe('fn', () => { { verbose: true }, ); })); + test('pre-concatenates string literals', asyncTest(async () => { const stack = new Stack(); fc.assert( @@ -113,6 +112,7 @@ describe('fn', () => { { verbose: true }, ); })); + test('pre-concatenates around tokens', asyncTest(async () => { const stack = new Stack(); fc.assert( @@ -125,6 +125,7 @@ describe('fn', () => { { verbose: true, seed: 1539874645005, path: '0:0:0:0:0:0:0:0:0' }, ); })); + test('flattens joins nested under joins with same delimiter', asyncTest(async () => { const stack = new Stack(); fc.assert( @@ -140,6 +141,7 @@ describe('fn', () => { { verbose: true }, ); })); + test('does not flatten joins nested under joins with different delimiter', asyncTest(async () => { const stack = new Stack(); fc.assert( @@ -160,6 +162,7 @@ describe('fn', () => { { verbose: true }, ); })); + test('Fn::EachMemberIn', asyncTest(async () => { const stack = new Stack(); const eachMemberIn = Fn.conditionEachMemberIn( @@ -200,6 +203,7 @@ describe('fn', () => { }); })); }); + describe('Ref', () => { test('returns a reference given a logical name', () => { const stack = new Stack(); @@ -209,6 +213,7 @@ describe('fn', () => { }); }); + test('nested Fn::Join with list token', () => { const stack = new Stack(); const inner = Fn.join(',', Token.asList({ NotReallyList: true })); @@ -222,7 +227,6 @@ describe('fn', () => { ], ], }); - }); }); diff --git a/packages/@aws-cdk/core/test/include.test.ts b/packages/@aws-cdk/core/test/include.test.ts index 235bcba228bc7..1969a894638a7 100644 --- a/packages/@aws-cdk/core/test/include.test.ts +++ b/packages/@aws-cdk/core/test/include.test.ts @@ -15,8 +15,6 @@ describeDeprecated('include', () => { MyResource2: { Type: 'ResourceType2' }, }, }); - - }); test('included templates can co-exist with elements created programmatically', () => { @@ -39,8 +37,6 @@ describeDeprecated('include', () => { }, Outputs: { MyOutput: { Description: 'Out!', Value: 'hey' } }, }); - - }); test('exception is thrown in construction if an entity from an included template has the same id as a programmatic entity', () => { @@ -52,7 +48,6 @@ describeDeprecated('include', () => { new CfnParameter(stack, 'MyParam', { type: 'Integer' }); // duplicate! expect(() => toCloudFormation(stack)).toThrow(); - }); test('correctly merges template sections that contain strings', () => { @@ -75,8 +70,6 @@ describeDeprecated('include', () => { AWSTemplateFormatVersion: '2010-09-09', Description: 'Test 1\nTest 2', }); - - }); }); diff --git a/packages/@aws-cdk/core/test/logical-id.test.ts b/packages/@aws-cdk/core/test/logical-id.test.ts index 5288e814cb304..4a3a6e7af2820 100644 --- a/packages/@aws-cdk/core/test/logical-id.test.ts +++ b/packages/@aws-cdk/core/test/logical-id.test.ts @@ -19,8 +19,6 @@ describe('logical id', () => { new CfnResource(AB, 'C', { type: 'Resource' }); // THEN: no exception - - }); test('special case: if the resource is top-level, a hash is not added', () => { @@ -36,8 +34,6 @@ describe('logical id', () => { expect(stack.resolve(r.logicalId)).toEqual('MyAwesomeness'); expect(stack.resolve(r2.logicalId)).toEqual('x'.repeat(255)); expect(stack.resolve(r3.logicalId)).toEqual('y'.repeat(255)); - - }); test('if resource is top-level and logical id is longer than allowed, it is trimmed with a hash', () => { @@ -49,7 +45,6 @@ describe('logical id', () => { // THEN expect(stack.resolve(r.logicalId)).toEqual('x'.repeat(240) + 'C7A139A2'); - }); test('Logical IDs can be renamed at the stack level', () => { @@ -64,8 +59,6 @@ describe('logical id', () => { // THEN const template = toCloudFormation(stack); expect('Renamed' in template.Resources).toEqual(true); - - }); test('Renames for objects that don\'t exist fail', () => { @@ -78,8 +71,6 @@ describe('logical id', () => { // THEN expect(() => toCloudFormation(stack)).toThrow(); - - }); test('ID Renames that collide with existing IDs should fail', () => { @@ -94,7 +85,6 @@ describe('logical id', () => { // THEN expect(() => toCloudFormation(stack)).toThrow(/Two objects have been assigned the same Logical ID/); - }); test('hashed naming scheme filters constructs named "Resource" from the human portion', () => { @@ -117,8 +107,6 @@ describe('logical id', () => { }, }, }); - - }); test('can transparently wrap constructs using "Default" id', () => { @@ -144,8 +132,6 @@ describe('logical id', () => { // THEN: same ID, same object expect(theId1).toEqual(theId2); - - }); test('non-alphanumeric characters are removed from the human part of the logical ID', () => { @@ -155,7 +141,6 @@ describe('logical id', () => { // same human part, different hash expect(val1).toEqual('FoobarB00mHelloWorldHorrayHorray640E99FB'); expect(val2).toEqual('FoobarB00mHelloWorldHorrayHorray744334FD'); - }); test('non-alphanumeric characters are removed even if the ID has only one component', () => { @@ -163,7 +148,6 @@ describe('logical id', () => { // same human part, different hash expect(val1).toEqual('Foobar'); - }); test('empty identifiers are not allowed', () => { @@ -175,7 +159,6 @@ describe('logical id', () => { // THEN expect(() => toCloudFormation(stack)).toThrow(/Logical ID must adhere to the regular expression/); - }); test('too large identifiers are truncated yet still remain unique', () => { @@ -196,8 +179,6 @@ describe('logical id', () => { expect(C1.logicalId.length).toBeLessThanOrEqual(255); expect(C2.logicalId.length).toBeLessThanOrEqual(255); expect(C1).not.toEqual(C2); - - }); test('Refs and dependencies will correctly reflect renames done at the stack level', () => { @@ -223,8 +204,6 @@ describe('logical id', () => { }, }, }); - - }); test('customize logical id allocation behavior by overriding `Stack.allocateLogicalId`', () => { @@ -259,7 +238,6 @@ describe('logical id', () => { TheC: { Type: 'Type::Of::C' }, }, }); - }); test('detects duplicate logical IDs in the same Stack caused by overrideLogicalId', () => { @@ -273,8 +251,6 @@ describe('logical id', () => { expect(() => { toCloudFormation(stack); }).toThrow(/section 'Resources' already contains 'C'/); - - }); }); diff --git a/packages/@aws-cdk/core/test/output.test.ts b/packages/@aws-cdk/core/test/output.test.ts index 4ad27198bf27e..32616e6b432de 100644 --- a/packages/@aws-cdk/core/test/output.test.ts +++ b/packages/@aws-cdk/core/test/output.test.ts @@ -30,7 +30,6 @@ describe('output', () => { }, }, }); - }); test('No export is created by default', () => { @@ -45,8 +44,6 @@ describe('output', () => { }, }, }); - - }); test('importValue can be used to obtain a Fn::ImportValue expression', () => { @@ -73,8 +70,6 @@ describe('output', () => { }, }, }); - - }); test('importValue used inside the same stack produces an error', () => { @@ -89,8 +84,6 @@ describe('output', () => { // THEN expect(() => toCloudFormation(stack)).toThrow(/should only be used in a different Stack/); - - }); test('error message if importValue is used and Output is not exported', () => { @@ -109,8 +102,6 @@ describe('output', () => { expect(() => { toCloudFormation(stack2); }).toThrow(/Add an exportName to the CfnOutput/); - - }); test('Verify maximum length of export name', () => { @@ -120,7 +111,5 @@ describe('output', () => { expect(errors).toEqual([ expect.stringContaining('Export name cannot exceed 255 characters'), ]); - - }); }); diff --git a/packages/@aws-cdk/core/test/parameter.test.ts b/packages/@aws-cdk/core/test/parameter.test.ts index 14f1bb12fa19e..381d5825efb2f 100644 --- a/packages/@aws-cdk/core/test/parameter.test.ts +++ b/packages/@aws-cdk/core/test/parameter.test.ts @@ -30,8 +30,6 @@ describe('parameter', () => { }, }, }); - - }); test('parameters are tokens, so they can be assigned without .ref and their Ref will be taken', () => { @@ -39,6 +37,5 @@ describe('parameter', () => { const param = new CfnParameter(stack, 'MyParam', { type: 'String' }); expect(stack.resolve(param)).toEqual({ Ref: 'MyParam' }); - }); }); diff --git a/packages/@aws-cdk/core/test/resource.test.ts b/packages/@aws-cdk/core/test/resource.test.ts index ed6e9eabd5ef7..d3dadcb056ff8 100644 --- a/packages/@aws-cdk/core/test/resource.test.ts +++ b/packages/@aws-cdk/core/test/resource.test.ts @@ -30,14 +30,11 @@ describe('resource', () => { }, }, }); - - }); test('resources must reside within a Stack and fail upon creation if not', () => { const root = new Root(); expect(() => new CfnResource(root, 'R1', { type: 'ResourceType' })).toThrow(); - }); test('all entities have a logical ID calculated based on their full path in the tree', () => { @@ -50,8 +47,6 @@ describe('resource', () => { expect(withoutHash(stack.resolve(res1.logicalId))).toEqual('level1childoflevel1'); expect(withoutHash(stack.resolve(res2.logicalId))).toEqual('level1level2level3childoflevel3'); - - }); test('resource.props can only be accessed by derived classes', () => { @@ -65,8 +60,6 @@ describe('resource', () => { MyResource: { Type: 'My::Counter', Properties: { Count: 13 } }, }, }); - - }); test('resource attributes can be retrieved using getAtt(s) or attribute properties', () => { @@ -95,8 +88,6 @@ describe('resource', () => { }, }, }); - - }); test('ARN-type resource attributes have some common functionality', () => { @@ -122,8 +113,6 @@ describe('resource', () => { }, }, }); - - }); test('resource.addDependency(e) can be used to add a DependsOn on another resource', () => { @@ -153,8 +142,6 @@ describe('resource', () => { Resource3: { Type: 'MyResourceType' }, }, }); - - }); test('if addDependency is called multiple times with the same resource, it will only appear once', () => { @@ -187,7 +174,6 @@ describe('resource', () => { }, }, }); - }); test('conditions can be attached to a resource', () => { @@ -200,8 +186,6 @@ describe('resource', () => { Resources: { Resource: { Type: 'Type', Condition: 'MyCondition' } }, Conditions: { MyCondition: { 'Fn::Not': [{ 'Fn::Equals': ['a', 'b'] }] } }, }); - - }); test('creation/update/updateReplace/deletion policies can be set on a resource', () => { @@ -241,8 +225,6 @@ describe('resource', () => { }, }, }); - - }); test('update policies UseOnlineResharding flag', () => { @@ -261,8 +243,6 @@ describe('resource', () => { }, }, }); - - }); test('metadata can be set on a resource', () => { @@ -285,14 +265,11 @@ describe('resource', () => { }, }, }); - - }); test('the "type" property is required when creating a resource', () => { const stack = new Stack(); expect(() => new CfnResource(stack, 'Resource', { notypehere: true } as any)).toThrow(); - }); test('removal policy is a high level abstraction of deletion policy used by l2', () => { @@ -316,7 +293,6 @@ describe('resource', () => { Default2: { Type: 'T4', DeletionPolicy: 'Retain', UpdateReplacePolicy: 'Retain' }, // implicit default }, }); - }); test('applyRemovalPolicy available for interface resources', () => { @@ -409,7 +385,6 @@ describe('resource', () => { }, }, }); - }); test('resource.ref returns the {Ref} token', () => { @@ -417,7 +392,6 @@ describe('resource', () => { const r = new CfnResource(stack, 'MyResource', { type: 'R' }); expect(stack.resolve(r.ref)).toEqual({ Ref: 'MyResource' }); - }); describe('overrides', () => { @@ -443,8 +417,6 @@ describe('resource', () => { }, }, }); - - }); test('addPropertyOverride() allows assigning an attribute of a different resource', () => { @@ -474,8 +446,6 @@ describe('resource', () => { }, }, }); - - }); test('addOverride(p, null) will assign an "null" value', () => { @@ -508,8 +478,6 @@ describe('resource', () => { }, }, }); - - }); test('addOverride(p, undefined) can be used to delete a value', () => { @@ -542,8 +510,6 @@ describe('resource', () => { }, }, }); - - }); test('addOverride(p, undefined) will not create empty trees', () => { @@ -567,8 +533,6 @@ describe('resource', () => { }, }, }); - - }); test('addDeletionOverride(p) and addPropertyDeletionOverride(pp) are sugar for `undefined`', () => { @@ -603,8 +567,6 @@ describe('resource', () => { }, }, }); - - }); test('addOverride(p, v) will overwrite any non-objects along the path', () => { @@ -641,7 +603,6 @@ describe('resource', () => { }, }, }); - }); test('addOverride(p, v) will not split on escaped dots', () => { @@ -674,7 +635,6 @@ describe('resource', () => { }, }, }); - }); test('addPropertyOverride(pp, v) is a sugar for overriding properties', () => { @@ -699,7 +659,6 @@ describe('resource', () => { }, }, }); - }); test('overrides are applied after render', () => { @@ -731,7 +690,6 @@ describe('resource', () => { }, }, }); - }); test('overrides allow overriding one intrinsic with another', () => { @@ -805,7 +763,6 @@ describe('resource', () => { }); describe('using mutable properties', () => { - test('can be used by derived classes to specify overrides before render()', () => { const stack = new Stack(); @@ -825,7 +782,6 @@ describe('resource', () => { }, }, }); - }); test('"properties" is undefined', () => { @@ -845,7 +801,6 @@ describe('resource', () => { }, }, }); - }); test('"properties" is empty', () => { @@ -866,7 +821,6 @@ describe('resource', () => { }, }, }); - }); }); }); @@ -891,8 +845,6 @@ describe('resource', () => { }, }, }); - - }); test('cross-stack construct dependencies are not rendered but turned into stack dependencies', () => { @@ -915,8 +867,6 @@ describe('resource', () => { // Notice absence of 'DependsOn' }); expect(stackB.dependencies.map(s => s.node.id)).toEqual(['StackA']); - - }); test('enableVersionUpgrade can be set on a resource', () => { @@ -937,8 +887,6 @@ describe('resource', () => { }, }, }); - - }); }); diff --git a/packages/@aws-cdk/core/test/rule.test.ts b/packages/@aws-cdk/core/test/rule.test.ts index 4914e7a7d271a..037cb46a4128b 100644 --- a/packages/@aws-cdk/core/test/rule.test.ts +++ b/packages/@aws-cdk/core/test/rule.test.ts @@ -25,8 +25,6 @@ describe('rule', () => { }, }, }); - - }); test('a template can contain multiple Rules', () => { @@ -41,7 +39,5 @@ describe('rule', () => { Rule2: {}, }, }); - - }); }); diff --git a/packages/@aws-cdk/core/test/stack.test.ts b/packages/@aws-cdk/core/test/stack.test.ts index dd83e954ed17b..48ae7d185d97f 100644 --- a/packages/@aws-cdk/core/test/stack.test.ts +++ b/packages/@aws-cdk/core/test/stack.test.ts @@ -43,7 +43,6 @@ describe('stack', () => { AWSTemplateFormatVersion: 'MyTemplateVersion', Transform: 'SAMy', }); - }); test('Stack.isStack indicates that a construct is a stack', () => { @@ -51,7 +50,6 @@ describe('stack', () => { const c = new Construct(stack, 'Construct'); expect(Stack.isStack(stack)).toBeDefined(); expect(!Stack.isStack(c)).toBeDefined(); - }); test('stack.id is not included in the logical identities of resources within it', () => { @@ -59,7 +57,6 @@ describe('stack', () => { new CfnResource(stack, 'MyResource', { type: 'MyResourceType' }); expect(toCloudFormation(stack)).toEqual({ Resources: { MyResource: { Type: 'MyResourceType' } } }); - }); test('when stackResourceLimit is default, should give error', () => { @@ -76,8 +73,6 @@ describe('stack', () => { expect(() => { app.synth(); }).toThrow('Number of resources in stack \'MyStack\': 1000 is greater than allowed maximum of 500'); - - }); test('when stackResourceLimit is defined, should give the proper error', () => { @@ -98,8 +93,6 @@ describe('stack', () => { expect(() => { app.synth(); }).toThrow('Number of resources in stack \'MyStack\': 200 is greater than allowed maximum of 100'); - - }); test('when stackResourceLimit is 0, should not give error', () => { @@ -120,8 +113,6 @@ describe('stack', () => { expect(() => { app.synth(); }).not.toThrow(); - - }); test('stack.templateOptions can be used to set template-level options', () => { @@ -141,8 +132,6 @@ describe('stack', () => { AWSTemplateFormatVersion: 'TemplateVersion', Metadata: { MetadataKey: 'MetadataValue' }, }); - - }); test('stack.templateOptions.transforms removes duplicate values', () => { @@ -153,8 +142,6 @@ describe('stack', () => { expect(toCloudFormation(stack)).toEqual({ Transform: ['A', 'B', 'C'], }); - - }); test('stack.addTransform() adds a transform', () => { @@ -167,8 +154,6 @@ describe('stack', () => { expect(toCloudFormation(stack)).toEqual({ Transform: ['A', 'B', 'C'], }); - - }); // This approach will only apply to TypeScript code, but at least it's a temporary @@ -205,8 +190,6 @@ describe('stack', () => { }, }, }); - - }); test('Stack.getByPath can be used to find any CloudFormation element (Parameter, Output, etc)', () => { @@ -220,8 +203,6 @@ describe('stack', () => { expect(stack.node.findChild(p.node.id)).toEqual(p); expect(stack.node.findChild(o.node.id)).toEqual(o); expect(stack.node.findChild(c.node.id)).toEqual(c); - - }); test('Stack names can have hyphens in them', () => { @@ -229,15 +210,12 @@ describe('stack', () => { new Stack(root, 'Hello-World'); // Did not throw - - }); test('Stacks can have a description given to them', () => { const stack = new Stack(new App(), 'MyStack', { description: 'My stack, hands off!' }); const output = toCloudFormation(stack); expect(output.Description).toEqual('My stack, hands off!'); - }); test('Stack descriptions have a limited length', () => { @@ -254,7 +232,6 @@ describe('stack', () => { aliquam malesuada bibendum arcu vitae. Augue neque gravida in fermentum et sollicitudin ac orci phasellus. Ultrices tincidunt arcu non sodales neque sodales.`; expect(() => new Stack(new App(), 'MyStack', { description: desc })); - }); testDeprecated('Include should support non-hash top-level template elements like "Description"', () => { @@ -269,7 +246,6 @@ describe('stack', () => { const output = toCloudFormation(stack); expect(typeof output.Description).toEqual('string'); - }); test('Pseudo values attached to one stack can be referenced in another stack', () => { @@ -304,8 +280,6 @@ describe('stack', () => { }, }, }); - - }); test('Cross-stack references are detected in resource properties', () => { @@ -367,7 +341,6 @@ describe('stack', () => { const theOutput = template1.Outputs[Object.keys(template1.Outputs)[0]]; expect(theOutput.Export.Name.length).toEqual(255); - }); test('Cross-stack reference export names are relative to the stack (when the flag is set)', () => { @@ -439,8 +412,6 @@ describe('stack', () => { }, }, }); - - }); test('Cross-stack use of Region and account returns nonscoped intrinsic because the two stacks must be in the same region anyway', () => { @@ -677,8 +648,6 @@ describe('stack', () => { // THEN resolveReferences(app); - - }); test('Stacks can be children of other stacks (substack) and they will be synthesized separately', () => { @@ -736,7 +705,6 @@ describe('stack', () => { }), }, })); - }); test('cross-stack reference (substack references parent stack)', () => { @@ -777,7 +745,6 @@ describe('stack', () => { }, }, }); - }); test('cross-stack reference (parent stack references substack)', () => { @@ -841,8 +808,6 @@ describe('stack', () => { app.synth(); // eslint-disable-next-line max-len }).toThrow("'Stack1' depends on 'Stack2' (Stack1 -> Stack2.AWS::AccountId). Adding this dependency (Stack2 -> Stack1.AWS::AccountId) would create a cyclic reference."); - - }); test('stacks know about their dependencies', () => { @@ -859,8 +824,6 @@ describe('stack', () => { // THEN expect(stack2.dependencies.map(s => s.node.id)).toEqual(['Stack1']); - - }); test('cannot create references to stacks in other regions/accounts', () => { @@ -876,8 +839,6 @@ describe('stack', () => { expect(() => { app.synth(); }).toThrow(/Stack "Stack2" cannot consume a cross reference from stack "Stack1"/); - - }); test('urlSuffix does not imply a stack dependency', () => { @@ -895,8 +856,6 @@ describe('stack', () => { app.synth(); expect(second.dependencies.length).toEqual(0); - - }); test('stack with region supplied via props returns literal value', () => { @@ -906,8 +865,6 @@ describe('stack', () => { // THEN expect(stack.resolve(stack.region)).toEqual('es-norst-1'); - - }); test('overrideLogicalId(id) can be used to override the logical ID of a resource', () => { @@ -942,7 +899,6 @@ describe('stack', () => { }, }, }); - }); test('Stack name can be overridden via properties', () => { @@ -951,8 +907,6 @@ describe('stack', () => { // THEN expect(stack.stackName).toEqual('otherName'); - - }); test('Stack name is inherited from App name if available', () => { @@ -963,8 +917,6 @@ describe('stack', () => { // THEN expect(stack.stackName).toEqual('ProdStackD5279B22'); - - }); test('stack construct id does not go through stack name validation if there is an explicit stack name', () => { @@ -980,7 +932,6 @@ describe('stack', () => { const session = app.synth(); expect(stack.stackName).toEqual('valid-stack-name'); expect(session.tryGetArtifact(stack.artifactId)).toBeDefined(); - }); test('stack validation is performed on explicit stack name', () => { @@ -990,8 +941,6 @@ describe('stack', () => { // THEN expect(() => new Stack(app, 'boom', { stackName: 'invalid:stack:name' })) .toThrow(/Stack name must match the regular expression/); - - }); test('Stack.of(stack) returns the correct stack', () => { @@ -1000,14 +949,12 @@ describe('stack', () => { const parent = new Construct(stack, 'Parent'); const construct = new Construct(parent, 'Construct'); expect(Stack.of(construct)).toBe(stack); - }); test('Stack.of() throws when there is no parent Stack', () => { const root = new Construct(undefined as any, 'Root'); const construct = new Construct(root, 'Construct'); expect(() => Stack.of(construct)).toThrow(/should be created in the scope of a Stack, but no Stack found/); - }); test('Stack.of() works for substacks', () => { @@ -1027,7 +974,6 @@ describe('stack', () => { expect(Stack.of(parentResource)).toBe(parentStack); expect(Stack.of(childStack)).toBe(childStack); expect(Stack.of(childResource)).toBe(childStack); - }); test('stack.availabilityZones falls back to Fn::GetAZ[0],[2] if region is not specified', () => { @@ -1043,7 +989,6 @@ describe('stack', () => { { 'Fn::Select': [0, { 'Fn::GetAZs': '' }] }, { 'Fn::Select': [1, { 'Fn::GetAZs': '' }] }, ]); - }); describe('@aws-cdk/core:enableStackNameDuplicates', () => { @@ -1109,7 +1054,6 @@ describe('stack', () => { expect(stack2.templateFile).toEqual('MyStack2.template.json'); }); }); - }); test('metadata is collected at the stack boundary', () => { @@ -1131,7 +1075,6 @@ describe('stack', () => { expect(asm.getStackByName(child.stackName).findMetadataByType('foo')).toEqual([ { path: '/parent/child', type: 'foo', data: 'bar' }, ]); - }); test('stack tags are reflected in the stack cloud assembly artifact metadata', () => { @@ -1155,7 +1098,6 @@ describe('stack', () => { expect(asm.getStackArtifact(stack1.artifactId).manifest.metadata).toEqual({ '/stack1': expected }); expect(asm.getStackArtifact(stack2.artifactId).manifest.metadata).toEqual({ '/stack1/stack2': expected }); - }); test('stack tags are reflected in the stack artifact properties', () => { @@ -1173,7 +1115,6 @@ describe('stack', () => { expect(asm.getStackArtifact(stack1.artifactId).tags).toEqual(expected); expect(asm.getStackArtifact(stack2.artifactId).tags).toEqual(expected); - }); test('Termination Protection is reflected in Cloud Assembly artifact', () => { @@ -1185,8 +1126,6 @@ describe('stack', () => { const artifact = assembly.getStackArtifact(stack.artifactId); expect(artifact.terminationProtection).toEqual(true); - - }); test('context can be set on a stack using a LegacySynthesizer', () => { @@ -1197,8 +1136,6 @@ describe('stack', () => { stack.node.setContext('something', 'value'); // THEN: no exception - - }); test('context can be set on a stack using a DefaultSynthesizer', () => { @@ -1209,26 +1146,21 @@ describe('stack', () => { stack.node.setContext('something', 'value'); // THEN: no exception - - }); test('version reporting can be configured on the app', () => { const app = new App({ analyticsReporting: true }); expect(new Stack(app, 'Stack')._versionReportingEnabled).toBeDefined(); - }); test('version reporting can be configured with context', () => { const app = new App({ context: { 'aws:cdk:version-reporting': true } }); expect(new Stack(app, 'Stack')._versionReportingEnabled).toBeDefined(); - }); test('version reporting can be configured on the stack', () => { const app = new App(); expect(new Stack(app, 'Stack', { analyticsReporting: true })._versionReportingEnabled).toBeDefined(); - }); test('requires bundling when wildcard is specified in BUNDLING_STACKS', () => { @@ -1236,7 +1168,6 @@ describe('stack', () => { const stack = new Stack(app, 'Stack'); stack.node.setContext(cxapi.BUNDLING_STACKS, ['*']); expect(stack.bundlingRequired).toBe(true); - }); test('requires bundling when stackName has an exact match in BUNDLING_STACKS', () => { @@ -1244,7 +1175,6 @@ describe('stack', () => { const stack = new Stack(app, 'Stack'); stack.node.setContext(cxapi.BUNDLING_STACKS, ['Stack']); expect(stack.bundlingRequired).toBe(true); - }); test('does not require bundling when no item from BUILDING_STACKS matches stackName', () => { @@ -1252,7 +1182,6 @@ describe('stack', () => { const stack = new Stack(app, 'Stack'); stack.node.setContext(cxapi.BUNDLING_STACKS, ['Stac']); expect(stack.bundlingRequired).toBe(false); - }); test('does not require bundling when BUNDLING_STACKS is empty', () => { @@ -1260,7 +1189,6 @@ describe('stack', () => { const stack = new Stack(app, 'Stack'); stack.node.setContext(cxapi.BUNDLING_STACKS, []); expect(stack.bundlingRequired).toBe(false); - }); }); diff --git a/packages/@aws-cdk/core/test/stage.test.ts b/packages/@aws-cdk/core/test/stage.test.ts index cf3d1906e7bc2..532515cea54ea 100644 --- a/packages/@aws-cdk/core/test/stage.test.ts +++ b/packages/@aws-cdk/core/test/stage.test.ts @@ -18,8 +18,6 @@ describe('stage', () => { // THEN expect(acctRegion(stack1)).toEqual(['account', 'elsewhere']); expect(acctRegion(stack2)).toEqual(['tnuocca', 'region']); - - }); test('envs are inherited deeply', () => { @@ -38,8 +36,6 @@ describe('stage', () => { expect(acctRegion(new Stack(innerAcct, 'Stack'))).toEqual(['tnuocca', 'region']); expect(acctRegion(new Stack(innerRegion, 'Stack'))).toEqual(['account', 'elsewhere']); expect(acctRegion(new Stack(innerNeither, 'Stack'))).toEqual(['account', 'region']); - - }); test('The Stage Assembly is in the app Assembly\'s manifest', () => { @@ -53,8 +49,6 @@ describe('stage', () => { const artifact = appAsm.artifacts.find(x => x instanceof cxapi.NestedCloudAssemblyArtifact); expect(artifact).toBeDefined(); - - }); test('Stacks in Stage are in a different cxasm than Stacks in App', () => { @@ -70,8 +64,6 @@ describe('stage', () => { const appAsm = app.synth(); expect(appAsm.stacks.map(s => s.stackName)).toEqual([stack1.stackName]); - - }); test('Can nest Stages inside other Stages', () => { @@ -87,8 +79,6 @@ describe('stage', () => { const innerAsm = outerAsm.getNestedAssembly(inner.artifactId); expect(innerAsm.tryGetArtifact(stack.artifactId)).toBeDefined(); - - }); test('Default stack name in Stage objects incorporates the Stage name and no hash', () => { @@ -100,8 +90,6 @@ describe('stage', () => { // THEN expect(stage.stageName).toEqual('MyStage'); expect(stack.stackName).toEqual('MyStage-MyStack'); - - }); test('Can not have dependencies to stacks outside the nested asm', () => { @@ -115,7 +103,6 @@ describe('stage', () => { expect(() => { stack2.addDependency(stack1); }).toThrow(/dependency cannot cross stage boundaries/); - }); test('When we synth() a stage, aspects inside it must have been applied', () => { @@ -134,8 +121,6 @@ describe('stage', () => { 'MyStage/Stack', 'MyStage/Stack/Resource', ]); - - }); test('Aspects do not apply inside a Stage', () => { @@ -154,7 +139,6 @@ describe('stage', () => { '', 'Tree', ]); - }); test('Automatic dependencies inside a stage are available immediately after synth', () => { @@ -181,8 +165,6 @@ describe('stage', () => { expect( asm.getStackArtifact(stack2.artifactId).dependencies.map(d => d.id)).toEqual( [stack1.artifactId]); - - }); test('Assemblies can be deeply nested', () => { @@ -228,8 +210,6 @@ describe('stage', () => { }, }, }); - - }); test('stage name validation', () => { @@ -246,8 +226,6 @@ describe('stage', () => { expect(() => new Stage(app, '&')).toThrow(/invalid stage name "&"/); expect(() => new Stage(app, '45hello')).toThrow(/invalid stage name "45hello"/); expect(() => new Stage(app, 'f')).toThrow(/invalid stage name "f"/); - - }); test('outdir cannot be specified for nested stages', () => { @@ -256,7 +234,6 @@ describe('stage', () => { // THEN expect(() => new Stage(app, 'mystage', { outdir: '/tmp/foo/bar' })).toThrow(/"outdir" cannot be specified for nested stages/); - }); test('Stage.isStage indicates that a construct is a stage', () => { @@ -269,7 +246,6 @@ describe('stage', () => { expect(Stage.isStage(stage)).toEqual(true); expect(Stage.isStage(app)).toEqual(true); expect(Stage.isStage(stack)).toEqual(false); - }); test('Stage.isStage indicates that a construct is a stage based on symbol', () => { @@ -285,7 +261,6 @@ describe('stage', () => { expect(Stage.isStage(stage)).toEqual(true); expect(Stage.isStage(app)).toEqual(true); expect(Stage.isStage(externalStage)).toEqual(true); - }); }); diff --git a/packages/@aws-cdk/core/test/staging.test.ts b/packages/@aws-cdk/core/test/staging.test.ts index 299c1964c1e85..f577ddf3b9024 100644 --- a/packages/@aws-cdk/core/test/staging.test.ts +++ b/packages/@aws-cdk/core/test/staging.test.ts @@ -86,7 +86,6 @@ describe('staging', () => { expect(staging.packaging).toEqual(FileAssetPackaging.FILE); expect(staging.isArchive).toEqual(true); - }); test('asset packaging type is correct when staging is skipped because of memory cache', () => { @@ -102,7 +101,6 @@ describe('staging', () => { expect(staging1.isArchive).toEqual(true); expect(staging2.packaging).toEqual(staging1.packaging); expect(staging2.isArchive).toEqual(staging1.isArchive); - }); test('asset packaging type is correct when staging is skipped because of disk cache', () => { @@ -135,8 +133,6 @@ describe('staging', () => { expect(staging1.isArchive).toEqual(true); expect(staging2.packaging).toEqual(staging1.packaging); expect(staging2.isArchive).toEqual(staging1.isArchive); - - }); test('staging of a non-archive file correctly sets packaging and isArchive', () => { @@ -149,7 +145,6 @@ describe('staging', () => { expect(staging.packaging).toEqual(FileAssetPackaging.FILE); expect(staging.isArchive).toEqual(false); - }); test('staging can be disabled through context', () => { @@ -165,7 +160,6 @@ describe('staging', () => { expect(staging.sourcePath).toEqual(sourcePath); expect(staging.absoluteStagedPath).toEqual(sourcePath); expect(staging.relativeStagedPath(stack)).toEqual(sourcePath); - }); test('files are copied to the output directory during synth', () => { @@ -187,7 +181,6 @@ describe('staging', () => { 'stack.template.json', 'tree.json', ]); - }); test('assets in nested assemblies get staged into assembly root directory', () => { @@ -212,7 +205,6 @@ describe('staging', () => { 'manifest.json', 'tree.json', ]); - }); test('allow specifying extra data to include in the source hash', () => { @@ -229,7 +221,6 @@ describe('staging', () => { expect(withoutExtra.assetHash).not.toEqual(withExtra.assetHash); expect(withoutExtra.assetHash).toEqual(FIXTURE_TEST1_HASH); expect(withExtra.assetHash).toEqual('c95c915a5722bb9019e2c725d11868e5a619b55f36172f76bcbcaa8bb2d10c5f'); - }); test('with bundling', () => { @@ -264,8 +255,6 @@ describe('staging', () => { // shows a message before bundling expect(processStdErrWriteSpy.calledWith('Bundling asset stack/Asset...\n')).toEqual(true); - - }); test('bundled resources have absolute path when staging is disabled', () => { @@ -302,8 +291,6 @@ describe('staging', () => { // absolute path ending with bundling dir expect(path.isAbsolute(resolvedStagePath)).toEqual(true); expect(new RegExp('asset.b1e32e86b3523f2fa512eb99180ee2975a50a4439e63e8badd153f2a68d61aa4$').test(resolvedStagePath)).toEqual(true); - - }); test('bundler reuses its output when it can', () => { @@ -345,8 +332,6 @@ describe('staging', () => { 'stack.template.json', 'tree.json', ]); - - }); test('uses asset hash cache with AssetHashType.OUTPUT', () => { @@ -395,8 +380,6 @@ describe('staging', () => { // Only one fingerprinting expect(fingerPrintSpy.calledOnce).toEqual(true); - - }); test('bundler considers its options when reusing bundle output', () => { @@ -444,8 +427,6 @@ describe('staging', () => { 'stack.template.json', 'tree.json', ]); - - }); test('bundler outputs to intermediate dir and renames to asset', () => { @@ -481,8 +462,6 @@ describe('staging', () => { 'stack.template.json', 'tree.json', ]); - - }); test('bundling failure preserves the bundleDir for diagnosability', () => { @@ -505,8 +484,6 @@ describe('staging', () => { const dir = fs.readdirSync(assembly.directory); expect(dir.some(entry => entry.match(/asset.*-error/))).toEqual(true); - - }); test('bundler re-uses assets from previous synths', () => { @@ -563,8 +540,6 @@ describe('staging', () => { 'stack.template.json', 'tree.json', ]); - - }); test('bundling throws when /asset-ouput is empty', () => { @@ -586,7 +561,6 @@ describe('staging', () => { readDockerStubInput()).toEqual( `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS_NO_OUTPUT`, ); - }); testDeprecated('bundling with BUNDLE asset hash type', () => { @@ -611,11 +585,8 @@ describe('staging', () => { `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS`, ); expect(asset.assetHash).toEqual('33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f'); - - }); - test('bundling with docker security option', () => { // GIVEN const app = new App(); @@ -639,8 +610,6 @@ describe('staging', () => { `run --rm --security-opt no-new-privileges ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS`, ); expect(asset.assetHash).toEqual('33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f'); - - }); test('bundling with OUTPUT asset hash type', () => { @@ -661,8 +630,6 @@ describe('staging', () => { // THEN expect(asset.assetHash).toEqual('33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f'); - - }); test('custom hash', () => { @@ -680,8 +647,6 @@ describe('staging', () => { // THEN expect(fs.existsSync(STUB_INPUT_FILE)).toEqual(false); expect(asset.assetHash).toEqual('b9c77053f5b83bbe5ba343bc18e92db939a49017010813225fea91fa892c4823'); // hash of 'my-custom-hash' - - }); test('throws with assetHash and not CUSTOM hash type', () => { @@ -700,8 +665,6 @@ describe('staging', () => { assetHash: 'my-custom-hash', assetHashType: AssetHashType.OUTPUT, })).toThrow(/Cannot specify `output` for `assetHashType`/); - - }); testDeprecated('throws with BUNDLE hash type and no bundling', () => { @@ -716,8 +679,6 @@ describe('staging', () => { assetHashType: AssetHashType.BUNDLE, })).toThrow(/Cannot use `bundle` hash type when `bundling` is not specified/); expect(fs.existsSync(STUB_INPUT_FILE)).toEqual(false); - - }); test('throws with OUTPUT hash type and no bundling', () => { @@ -732,8 +693,6 @@ describe('staging', () => { assetHashType: AssetHashType.OUTPUT, })).toThrow(/Cannot use `output` hash type when `bundling` is not specified/); expect(fs.existsSync(STUB_INPUT_FILE)).toEqual(false); - - }); test('throws with CUSTOM and no hash', () => { @@ -748,8 +707,6 @@ describe('staging', () => { assetHashType: AssetHashType.CUSTOM, })).toThrow(/`assetHash` must be specified when `assetHashType` is set to `AssetHashType.CUSTOM`/); expect(fs.existsSync(STUB_INPUT_FILE)).toEqual(false); // "docker" not executed - - }); test('throws when bundling fails', () => { @@ -770,8 +727,6 @@ describe('staging', () => { readDockerStubInput()).toEqual( `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input this-is-an-invalid-docker-image DOCKER_STUB_FAIL`, ); - - }); test('with local bundling', () => { @@ -807,8 +762,6 @@ describe('staging', () => { if (dir) { fs.removeSync(path.join(dir, 'hello.txt')); } - - }); test('with local bundling returning false', () => { @@ -833,8 +786,6 @@ describe('staging', () => { // THEN expect(readDockerStubInput()).toBeDefined(); - - }); test('bundling can be skipped by setting context', () => { @@ -919,8 +870,6 @@ describe('staging', () => { `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS`, ); expect(asset.assetHash).toEqual('33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f'); // hash of MyStack/Asset - - }); test('bundling still occurs with full wildcard', () => { @@ -945,8 +894,6 @@ describe('staging', () => { `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS`, ); expect(asset.assetHash).toEqual('33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f'); // hash of MyStack/Asset - - }); test('bundling that produces a single archive file is autodiscovered', () => { @@ -979,8 +926,6 @@ describe('staging', () => { ]); expect(staging.packaging).toEqual(FileAssetPackaging.FILE); expect(staging.isArchive).toEqual(true); - - }); test('bundling that produces a single archive file with disk cache', () => { @@ -1027,8 +972,6 @@ describe('staging', () => { expect(staging1.isArchive).toEqual(true); expect(staging2.packaging).toEqual(staging1.packaging); expect(staging2.isArchive).toEqual(staging1.isArchive); - - }); test('bundling that produces a single archive file with NOT_ARCHIVED', () => { @@ -1058,8 +1001,6 @@ describe('staging', () => { ]); expect(staging.packaging).toEqual(FileAssetPackaging.ZIP_DIRECTORY); expect(staging.isArchive).toEqual(true); - - }); test('throws with ARCHIVED and bundling that does not produce a single archive file', () => { @@ -1077,8 +1018,6 @@ describe('staging', () => { outputType: BundlingOutput.ARCHIVED, }, })).toThrow(/Bundling output directory is expected to include only a single .zip or .jar file when `output` is set to `ARCHIVED`/); - - }); }); diff --git a/packages/@aws-cdk/core/test/tag-aspect.test.ts b/packages/@aws-cdk/core/test/tag-aspect.test.ts index 001c07061ba22..8695f4e1393bb 100644 --- a/packages/@aws-cdk/core/test/tag-aspect.test.ts +++ b/packages/@aws-cdk/core/test/tag-aspect.test.ts @@ -62,8 +62,8 @@ describe('tag aspect', () => { expect(res2.tags.renderTags()).toEqual([{ key: 'foo', value: 'bar' }]); expect(map.tags.renderTags()).toEqual({ foo: 'bar' }); expect(asg.tags.renderTags()).toEqual([{ key: 'foo', value: 'bar', propagateAtLaunch: true }]); - }); + test('The last aspect applied takes precedence', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -79,8 +79,8 @@ describe('tag aspect', () => { synthesize(root); expect(res.tags.renderTags()).toEqual([{ key: 'foo', value: 'baz' }]); expect(res2.tags.renderTags()).toEqual([{ key: 'foo', value: 'good' }]); - }); + test('RemoveTag will remove a tag if it exists', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -106,8 +106,8 @@ describe('tag aspect', () => { expect(map.tags.renderTags()).toEqual({ first: 'there is only 1' }); expect(asg.tags.renderTags()).toEqual([{ key: 'first', value: 'there is only 1', propagateAtLaunch: true }]); expect(res2.tags.renderTags()).toEqual([{ key: 'first', value: 'there is only 1' }]); - }); + test('add will add a tag and remove will remove a tag if it exists', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -134,8 +134,8 @@ describe('tag aspect', () => { expect(map.tags.renderTags()).toEqual({ first: 'there is only 1' }); expect(asg.tags.renderTags()).toEqual([{ key: 'first', value: 'there is only 1', propagateAtLaunch: true }]); expect(res2.tags.renderTags()).toEqual([{ key: 'first', value: 'there is only 1' }]); - }); + test('the #visit function is idempotent', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -149,8 +149,8 @@ describe('tag aspect', () => { expect(res.tags.renderTags()).toEqual([{ key: 'foo', value: 'bar' }]); synthesize(root); expect(res.tags.renderTags()).toEqual([{ key: 'foo', value: 'bar' }]); - }); + test('removeTag Aspects by default will override child Tag Aspects', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -164,8 +164,8 @@ describe('tag aspect', () => { synthesize(root); expect(res.tags.renderTags()).toEqual(undefined); expect(res2.tags.renderTags()).toEqual(undefined); - }); + test('removeTag Aspects with priority 0 will not override child Tag Aspects', () => { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -179,8 +179,8 @@ describe('tag aspect', () => { synthesize(root); expect(res.tags.renderTags()).toEqual(undefined); expect(res2.tags.renderTags()).toEqual([{ key: 'key', value: 'value' }]); - }); + test('Aspects are merged with tags created by L1 Constructor', () => { const root = new Stack(); const aspectBranch = new TaggableResource(root, 'FakeBranchA', { @@ -230,8 +230,8 @@ describe('tag aspect', () => { cfn: 'is cool', }); expect(cfnBranch.testProperties().tags).toEqual([{ key: 'cfn', value: 'is cool' }]); - }); + describe('when invalid tag properties are passed from L1s', () => { test('map passed instead of array it raises', () => { const root = new Stack(); @@ -258,8 +258,8 @@ describe('tag aspect', () => { }, }); }).toThrow(); - }); + test('if array is passed instead of map it raises', () => { const root = new Stack(); expect(() => { @@ -273,7 +273,6 @@ describe('tag aspect', () => { }, }); }).toThrow(); - }); }); }); diff --git a/packages/@aws-cdk/core/test/tag-manager.test.ts b/packages/@aws-cdk/core/test/tag-manager.test.ts index 79b764f6c13b0..5911447e1ea6a 100644 --- a/packages/@aws-cdk/core/test/tag-manager.test.ts +++ b/packages/@aws-cdk/core/test/tag-manager.test.ts @@ -7,55 +7,55 @@ describe('tag manager', () => { const mgr = new TagManager(TagType.MAP, 'Foo', undefined, { tagPropertyName: tagPropName }); expect(mgr.tagPropertyName).toEqual(tagPropName); - }); + test('#setTag() supports setting a tag regardless of Type', () => { const notTaggable = new TagManager(TagType.NOT_TAGGABLE, 'AWS::Resource::Type'); notTaggable.setTag('key', 'value'); expect(notTaggable.renderTags()).toEqual(undefined); - }); + describe('when a tag does not exist', () => { test('#removeTag() does not throw an error', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); expect(() => (mgr.removeTag('dne', 0))).not.toThrow(); - }); + test('#setTag() creates the tag', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('dne', 'notanymore'); expect(mgr.renderTags()).toEqual([{ key: 'dne', value: 'notanymore' }]); - }); }); + describe('when a tag does exist', () => { test('#removeTag() deletes the tag', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('dne', 'notanymore', 0); mgr.removeTag('dne', 0); expect(mgr.renderTags()).toEqual(undefined); - }); + test('#setTag() overwrites the tag', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('dne', 'notanymore'); mgr.setTag('dne', 'iwin'); expect(mgr.renderTags()).toEqual([{ key: 'dne', value: 'iwin' }]); - }); }); + describe('when there are no tags', () => { test('#renderTags() returns undefined', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); expect(mgr.renderTags()).toEqual(undefined); - }); + test('#hasTags() returns false', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); expect(mgr.hasTags()).toEqual(false); - }); }); + test('#renderTags() handles standard, map, keyValue, and ASG tag formats', () => { const tagged: TagManager[] = []; const standard = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); @@ -86,15 +86,15 @@ describe('tag manager', () => { foo: 'bar', asg: 'only', }); - }); + test('when there are tags it hasTags returns true', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('key', 'myVal', 2); mgr.setTag('key', 'newVal', 1); expect(mgr.hasTags()).toEqual(true); - }); + test('tags with higher or equal priority always take precedence', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('key', 'myVal', 2); @@ -108,8 +108,8 @@ describe('tag manager', () => { ]); mgr.removeTag('key', 2); expect(mgr.renderTags()).toEqual(undefined); - }); + test('tags are always ordered by key name', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Resource::Type'); mgr.setTag('key', 'foo'); @@ -127,22 +127,19 @@ describe('tag manager', () => { { key: 'myKey', value: 'myVal' }, { key: 'name', value: 'test' }, ]); - }); + test('excludeResourceTypes only tags resources that do not match', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Fake::Resource'); expect(false).toEqual(mgr.applyTagAspectHere([], ['AWS::Fake::Resource'])); expect(true).toEqual(mgr.applyTagAspectHere([], ['AWS::Wrong::Resource'])); - - }); + test('includeResourceTypes only tags resources that match', () => { const mgr = new TagManager(TagType.STANDARD, 'AWS::Fake::Resource'); expect(true).toEqual(mgr.applyTagAspectHere(['AWS::Fake::Resource'], [])); expect(false).toEqual(mgr.applyTagAspectHere(['AWS::Wrong::Resource'], [])); - - }); }); diff --git a/packages/@aws-cdk/core/test/tokens.test.ts b/packages/@aws-cdk/core/test/tokens.test.ts index 03384be3d7f0d..57bb8ff272bf7 100644 --- a/packages/@aws-cdk/core/test/tokens.test.ts +++ b/packages/@aws-cdk/core/test/tokens.test.ts @@ -10,7 +10,6 @@ describe('tokens', () => { test('resolve a plain old object should just return the object', () => { const obj = { PlainOldObject: 123, Array: [1, 2, 3] }; expect(resolve(obj)).toEqual(obj); - }); test('if a value is an object with a token value, it will be evaluated', () => { @@ -23,8 +22,6 @@ describe('tokens', () => { RegularValue: 'hello', LazyValue: 'World', }); - - }); test('tokens are evaluated anywhere in the object tree', () => { @@ -49,8 +46,6 @@ describe('tokens', () => { }, ], }); - - }); test('tokens are evaluated recursively', () => { @@ -75,8 +70,6 @@ describe('tokens', () => { }, ], }); - - }); test('empty arrays or objects are kept', () => { @@ -110,34 +103,28 @@ describe('tokens', () => { }, }, }); - - }); test('if an object has a "resolve" property that is not a function, it is not considered a token', () => { expect(resolve({ a_token: { resolve: () => 78787 } })).toEqual({ a_token: 78787 }); expect(resolve({ not_a_token: { resolve: 12 } })).toEqual({ not_a_token: { resolve: 12 } }); - }); // eslint-disable-next-line max-len test('if a resolvable object inherits from a class that is also resolvable, the "constructor" function will not get in the way (uses Object.keys instead of "for in")', () => { expect(resolve({ prop: new DataType() })).toEqual({ prop: { foo: 12, goo: 'hello' } }); - }); test('isToken(obj) can be used to determine if an object is a token', () => { expect(isResolvableObject({ resolve: () => 123 })).toEqual(true); expect(isResolvableObject({ a: 1, b: 2, resolve: () => 'hello' })).toEqual(true); expect(isResolvableObject({ a: 1, b: 2, resolve: 3 })).toEqual(false); - }); test('Token can be used to create tokens that contain a constant value', () => { expect(resolve(new Intrinsic(12))).toEqual(12); expect(resolve(new Intrinsic('hello'))).toEqual('hello'); expect(resolve(new Intrinsic(['hi', 'there']))).toEqual(['hi', 'there']); - }); test('resolving leaves a Date object in working order', () => { @@ -145,7 +132,6 @@ describe('tokens', () => { const resolved = resolve(date); expect(date.toString()).toEqual(resolved.toString()); - }); test('tokens can be stringified and evaluated to conceptual value', () => { @@ -158,7 +144,6 @@ describe('tokens', () => { // THEN expect(evaluateCFN(resolved)).toEqual('The dog says: woof woof'); - }); test('tokens stringification can be reversed', () => { @@ -167,7 +152,6 @@ describe('tokens', () => { // THEN expect(token).toEqual(Tokenization.reverseString(`${token}`).firstToken); - }); test('Tokens stringification and reversing of CloudFormation Tokens is implemented using Fn::Join', () => { @@ -182,7 +166,6 @@ describe('tokens', () => { expect(resolved).toEqual({ 'Fn::Join': ['', ['The dog says: ', { woof: 'woof' }]], }); - }); test('Doubly nested strings evaluate correctly in scalar context', () => { @@ -197,8 +180,6 @@ describe('tokens', () => { // THEN expect(evaluateCFN(resolved1)).toEqual('hello world'); expect(evaluateCFN(resolved2)).toEqual('hello world'); - - }); test('integer Tokens can be stringified and evaluate to conceptual value', () => { @@ -211,7 +192,6 @@ describe('tokens', () => { // THEN expect(evaluateCFN(resolved)).toEqual('the number is 1'); } - }); test('intrinsic Tokens can be stringified and evaluate to conceptual value', () => { @@ -224,8 +204,6 @@ describe('tokens', () => { const context = { MyBucket: 'TheName' }; expect(evaluateCFN(resolved, context)).toEqual('my bucket is named TheName'); } - - }); test('tokens resolve properly in initial position', () => { @@ -237,8 +215,6 @@ describe('tokens', () => { // THEN expect(evaluateCFN(resolved)).toEqual('Hello world'); } - - }); test('side-by-side Tokens resolve correctly', () => { @@ -252,8 +228,6 @@ describe('tokens', () => { expect(evaluateCFN(resolved)).toEqual('Hello world'); } } - - }); test('tokens can be used in hash keys but must resolve to a string', () => { @@ -267,7 +241,6 @@ describe('tokens', () => { // THEN expect(resolve(s)).toEqual({ 'I am a string': 'boom I am a string' }); - }); test('tokens can be nested in hash keys', () => { @@ -281,7 +254,6 @@ describe('tokens', () => { // THEN expect(resolve(s)).toEqual({ 'I am a string': 'boom I am a string' }); - }); test('Function passed to Lazy.uncachedString() is evaluated multiple times', () => { @@ -292,8 +264,6 @@ describe('tokens', () => { // THEN expect(resolve(counterString)).toEqual('1'); expect(resolve(counterString)).toEqual('2'); - - }); test('Function passed to Lazy.string() is only evaluated once', () => { @@ -304,8 +274,6 @@ describe('tokens', () => { // THEN expect(resolve(counterString)).toEqual('1'); expect(resolve(counterString)).toEqual('1'); - - }); test('Uncached tokens returned by cached tokens are still evaluated multiple times', () => { @@ -329,8 +297,6 @@ describe('tokens', () => { expect(resolve(counterString2)).toEqual('->3'); expect(resolve(counterString2)).toEqual('->4'); expect(resolve(counterObject)).toEqual({ finalCount: '5' }); - - }); test('tokens can be nested and concatenated in hash keys', () => { @@ -345,7 +311,6 @@ describe('tokens', () => { // THEN expect(resolve(s)).toEqual({ 'toot the woot': 'boom chicago' }); - }); test('can find nested tokens in hash keys', () => { @@ -362,7 +327,6 @@ describe('tokens', () => { const tokens = findTokens(new Stack(), () => s); expect(tokens.some(t => t === innerToken)).toEqual(true); expect(tokens.some(t => t === token)).toEqual(true); - }); test('fails if token in a hash key resolves to a non-string', () => { @@ -376,7 +340,6 @@ describe('tokens', () => { // THEN expect(() => resolve(s)).toThrow('is used as the key in a map so must resolve to a string, but it resolves to:'); - }); describe('list encoding', () => { @@ -393,8 +356,6 @@ describe('tokens', () => { expect(resolve(struct)).toEqual({ XYZ: { Ref: 'Other' }, }); - - }); test('cannot add to encoded list', () => { @@ -409,8 +370,6 @@ describe('tokens', () => { expect(() => { resolve(encoded); }).toThrow(/Cannot add elements to list token/); - - }); test('cannot add to strings in encoded list', () => { @@ -425,8 +384,6 @@ describe('tokens', () => { expect(() => { resolve(encoded); }).toThrow(/concatenate strings in/); - - }); test('can pass encoded lists to FnSelect', () => { @@ -440,8 +397,6 @@ describe('tokens', () => { expect(resolve(struct)).toEqual({ 'Fn::Select': [1, { Ref: 'Other' }], }); - - }); test('can pass encoded lists to FnJoin', () => { @@ -455,8 +410,6 @@ describe('tokens', () => { expect(resolve(struct)).toEqual({ 'Fn::Join': ['/', { Ref: 'Other' }], }); - - }); test('can pass encoded lists to FnJoin, even if join is stringified', () => { @@ -470,8 +423,6 @@ describe('tokens', () => { expect(resolve(struct)).toEqual({ 'Fn::Join': ['/', { Ref: 'Other' }], }); - - }); test('detect and error when list token values are illegally extracted', () => { @@ -619,11 +570,9 @@ describe('tokens', () => { const token = fn1(); restoreStackTraceColection(previousValue); expect(() => token.throwError('message!')).toThrow(/Token created:/); - }); describe('type coercion', () => { - const inputs = [ 'a string', 1234, @@ -643,50 +592,40 @@ describe('tokens', () => { test(`${input}.toNumber()`, () => { expect(resolve(Token.asNumber(new Intrinsic(stringToken)))).toEqual(expected); - }); test(`${input}.toNumber()`, () => { expect(resolve(Token.asNumber(new Intrinsic(listToken)))).toEqual(expected); - }); test(`${input}.toNumber()`, () => { expect(resolve(Token.asNumber(new Intrinsic(numberToken)))).toEqual(expected); - }); test(`${input}.toString()`, () => { expect(resolve(new Intrinsic(stringToken).toString())).toEqual(expected); - }); test(`${input}.toString()`, () => { expect(resolve(new Intrinsic(listToken).toString())).toEqual(expected); - }); test(`${input}.toString()`, () => { expect(resolve(new Intrinsic(numberToken).toString())).toEqual(expected); - }); test(`${input}.toList()`, () => { expect(resolve(Token.asList(new Intrinsic(stringToken)))).toEqual(expected); - }); test(`${input}.toList()`, () => { expect(resolve(Token.asList(new Intrinsic(listToken)))).toEqual(expected); - }); test(`${input}.toList()`, () => { expect(resolve(Token.asList(new Intrinsic(numberToken)))).toEqual(expected); - }); } - }); test('creation stack is attached to errors emitted during resolve with CDK_DEBUG=true', () => { @@ -708,7 +647,6 @@ describe('tokens', () => { } expect(message && message.includes('showMeInTheStackTrace')).toEqual(true); - }); test('creation stack is omitted without CDK_DEBUG=true', () => { @@ -730,7 +668,6 @@ describe('tokens', () => { } expect(message && message.includes('Execute again with CDK_DEBUG=true')).toEqual(true); - }); describe('stringifyNumber', () => { @@ -761,7 +698,6 @@ describe('tokens', () => { const res = Tokenization.stringifyNumber(tokenizedVal as any) as any; expect(res).not.toEqual(resolvedVal); expect(resolve(res)).toEqual(resolvedVal); - }); test('tokenized Ref remains the same', () => { @@ -770,7 +706,6 @@ describe('tokens', () => { const res = Tokenization.stringifyNumber(tokenizedVal) as any; expect(res).not.toEqual(resolvedVal); expect(resolve(res)).toEqual(resolvedVal); - }); }); }); diff --git a/packages/@aws-cdk/core/test/util.test.ts b/packages/@aws-cdk/core/test/util.test.ts index f9a0de0eb6b36..1efa0f5a5c7b6 100644 --- a/packages/@aws-cdk/core/test/util.test.ts +++ b/packages/@aws-cdk/core/test/util.test.ts @@ -24,43 +24,35 @@ describe('util', () => { expect(capitalizePropertyNames(c, { hello: { resolve: () => ({ foo: 'bar' }) }, world: new SomeToken() })).toEqual( { Hello: { Foo: 'bar' }, World: 100 }); - - }); describe('ignoreEmpty', () => { - test('[]', () => { const stack = new Stack(); expect(stack.resolve(ignoreEmpty([]))).toEqual(undefined); - }); test('{}', () => { const stack = new Stack(); expect(stack.resolve(ignoreEmpty({}))).toEqual(undefined); - }); test('undefined/null', () => { const stack = new Stack(); expect(stack.resolve(ignoreEmpty(undefined))).toEqual(undefined); expect(stack.resolve(ignoreEmpty(null))).toEqual(null); - }); test('primitives', () => { const stack = new Stack(); expect(stack.resolve(ignoreEmpty(12))).toEqual(12); expect(stack.resolve(ignoreEmpty('12'))).toEqual('12'); - }); test('non-empty arrays/objects', () => { const stack = new Stack(); expect(stack.resolve(ignoreEmpty([1, 2, 3, undefined]))).toEqual([1, 2, 3]); // undefined array values is cleaned up by "resolve" expect(stack.resolve(ignoreEmpty({ o: 1, b: 2, j: 3 }))).toEqual({ o: 1, b: 2, j: 3 }); - }); test('resolve first', () => { @@ -69,19 +61,16 @@ describe('util', () => { expect(stack.resolve(ignoreEmpty({ xoo: { resolve: () => undefined } }))).toEqual(undefined); expect(stack.resolve(ignoreEmpty({ xoo: { resolve: () => [] } }))).toEqual({ xoo: [] }); expect(stack.resolve(ignoreEmpty({ xoo: { resolve: () => [undefined, undefined] } }))).toEqual({ xoo: [] }); - }); }); describe('filterUnderined', () => { test('is null-safe (aka treats null and undefined the same)', () => { expect(filterUndefined({ 'a null': null, 'a not null': true })).toEqual({ 'a not null': true }); - }); test('removes undefined, but leaves the rest', () => { expect(filterUndefined({ 'an undefined': undefined, 'yes': true })).toEqual({ yes: true }); - }); }); @@ -93,8 +82,6 @@ describe('util', () => { expect(path(aaa)).toEqual(['a', 'aa', 'aaa']); expect(path(aa)).toEqual(['a', 'aa']); expect(path(a)).toEqual(['a']); - - function path(s: Stack) { return pathToTopLevelStack(s).map(x => x.node.id); } @@ -127,7 +114,6 @@ describe('util', () => { expect(lca(aaa, ba)).toEqual(undefined); expect(lca(baa, ba)).toEqual('ba'); - function lca(s1: Stack, s2: Stack) { const res = findLastCommonElement(pathToTopLevelStack(s1), pathToTopLevelStack(s2)); if (!res) { return undefined; }