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 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/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, 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); });