From eecf1b3a837b5f39f62c13319d4b2e011275218c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Wed, 10 Jul 2024 14:47:17 +0200 Subject: [PATCH 1/3] Add missing icon for unknown component --- src/models/TerraformConfiguration.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/models/TerraformConfiguration.js b/src/models/TerraformConfiguration.js index 74e59ac..51c3c70 100644 --- a/src/models/TerraformConfiguration.js +++ b/src/models/TerraformConfiguration.js @@ -38,6 +38,9 @@ class TerraformConfiguration extends DefaultConfiguration { }, { type: 'icons', name: 'resize', + }, { + type: 'icons', + name: 'unknown', }], container: { margin: 15, From 0f350ca8ede675f60c382f3f59324eeae96f1049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Wed, 10 Jul 2024 15:00:46 +0200 Subject: [PATCH 2/3] Fix number as string for count --- src/drawer/render/TerraformComponentRenderer.js | 7 ++++--- .../unit/drawer/render/TerraformComponentRenderer.spec.js | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/drawer/render/TerraformComponentRenderer.js b/src/drawer/render/TerraformComponentRenderer.js index 2a8e765..be9f6e3 100644 --- a/src/drawer/render/TerraformComponentRenderer.js +++ b/src/drawer/render/TerraformComponentRenderer.js @@ -11,11 +11,12 @@ class TerraformComponentRenderer extends ComponentRenderer { */ getTemplateData(component) { const countAttribute = component.getAttributeByName('count'); - const hasCount = !!countAttribute && countAttribute.value !== 1; + const countValue = parseInt(countAttribute?.value, 10); + const hasCount = !!countAttribute && countValue !== 1; let count = '?'; - if (hasCount && countAttribute.type === 'Number') { - count = countAttribute.value; + if (hasCount && Number.isInteger(countValue)) { + count = countValue; } return { diff --git a/tests/unit/drawer/render/TerraformComponentRenderer.spec.js b/tests/unit/drawer/render/TerraformComponentRenderer.spec.js index 160e971..a0d1b89 100644 --- a/tests/unit/drawer/render/TerraformComponentRenderer.spec.js +++ b/tests/unit/drawer/render/TerraformComponentRenderer.spec.js @@ -55,12 +55,13 @@ describe('Test class: TerraformComponentRenderer', () => { definition: new TerraformComponentDefinition(), attributes: [new TerraformComponentAttribute({ name: 'count', - type: 'Number', - value: 2, + type: 'String', + value: '2', })], }); const result = renderer.getTemplateData(component); + expect(result.hasCount).toEqual(true); expect(result.count).toBe(2); }); From 8ed74074a04ac3d80532651823ec74e300af03b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Wed, 10 Jul 2024 14:48:06 +0200 Subject: [PATCH 3/3] Update changelog --- changelog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog.md b/changelog.md index f091d75..bcb3852 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) +## [Unreleased] + +### Fixed + +- Register missing icon for unknown component. +- Fix string as number for count attribute. + ## [0.9.0] - 2024/07/09 ### Added