From 70643842391556161f38d9eac8626b85b6cd8f58 Mon Sep 17 00:00:00 2001 From: Toby Buckley <74737385+tobuck-aws@users.noreply.github.com> Date: Thu, 30 May 2024 15:32:49 -0700 Subject: [PATCH] Tags => tag (#48) --- src/utils/utils.ts | 6 +++--- test/utils.test.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 2a1df19..b1f21d6 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -25,9 +25,9 @@ export const addTemplateTag = (construct: Construct, tag: string) => { const appendTagToDescription = (existingDescription: string, newTag: string): string => { // Check if the existing description already has tags - if (existingDescription.includes('(Tags:')) { + if (existingDescription.includes('(tag:')) { // Extract the existing tags - const startIndex = existingDescription.indexOf('(Tags:') + 6; + const startIndex = existingDescription.indexOf('(tag:') + 6; const endIndex = existingDescription.lastIndexOf(')'); const existingTags = existingDescription.substring(startIndex, endIndex).split(', '); @@ -43,6 +43,6 @@ const appendTagToDescription = (existingDescription: string, newTag: string): st } } else { // Append the new tag to the description - return `${existingDescription} (Tags: ${newTag})`; + return `${existingDescription} (tag: ${newTag})`; } }; diff --git a/test/utils.test.ts b/test/utils.test.ts index d46a4e0..2cb9f8d 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -10,7 +10,7 @@ describe('addTemplateTag', () => { it('should append telemetry and tags to existing template description', () => { const stackA = new Stack(app, 'TestStackA', { description: 'test' }); const newTag = 'new-tag'; - const expectedDescription = `test - ${telemetryConst} (Tags: new-tag)`; + const expectedDescription = `test - ${telemetryConst} (tag: new-tag)`; addTemplateTag(stackA, newTag); expect(stackA.templateOptions.description).toBe(expectedDescription); }); @@ -18,25 +18,25 @@ describe('addTemplateTag', () => { it('should append a new tag to the description if it does not have any tags', () => { const stackB = new Stack(app, 'TestStackB'); const newTag = 'new-tag'; - const expectedDescription = `${telemetryConst} (Tags: new-tag)`; + const expectedDescription = `${telemetryConst} (tag: new-tag)`; addTemplateTag(stackB, newTag); expect(stackB.templateOptions.description).toBe(expectedDescription); }); it('should append a new tag to the existing tags in the description', () => { - const existingDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2)`; + const existingDescription = `This is a sample description - ${telemetryConst} (tag: tag1, tag2)`; const stackC = new Stack(app, 'TestStackC', { description: existingDescription }); const newTag = 'new-tag'; - const expectedDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; + const expectedDescription = `This is a sample description - ${telemetryConst} (tag: tag1, tag2, new-tag)`; addTemplateTag(stackC, newTag); expect(stackC.templateOptions.description).toBe(expectedDescription); }); it('should not append a new tag if it already exists in the description', () => { - const existingDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; + const existingDescription = `This is a sample description - ${telemetryConst} (tag: tag1, tag2, new-tag)`; const stackD = new Stack(app, 'TestStackD', { description: existingDescription }); const newTag = 'new-tag'; - const expectedDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; + const expectedDescription = `This is a sample description - ${telemetryConst} (tag: tag1, tag2, new-tag)`; addTemplateTag(stackD, newTag); expect(stackD.templateOptions.description).toBe(expectedDescription); });