From 1af491488ee2cc3f595e9dcef6f8feb707a11b4a Mon Sep 17 00:00:00 2001 From: Vitor Araujo Date: Sat, 1 Jul 2023 18:19:17 -0300 Subject: [PATCH] fix(entity2diagram): fix display of Array Fields in HerbsShelf fixes a bug where array fields in HerbsShelf were incorrectly displayed as 'undefined'. fix https://github.com/herbsjs/herbs2mermaid/issues/6 --- src/entity2diagram.js | 2 +- src/entity2diagram.test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/entity2diagram.js b/src/entity2diagram.js index fe7e791..6dcfa42 100644 --- a/src/entity2diagram.js +++ b/src/entity2diagram.js @@ -85,7 +85,7 @@ function fieldTypeDescription(entities, type) { return findEntityIdByName(entities, type.name) if (Array.isArray(type)) { - return `${type.name}[]` + return `${type[0].name}[]` } return type.name diff --git a/src/entity2diagram.test.js b/src/entity2diagram.test.js index dd1e044..b002f56 100644 --- a/src/entity2diagram.test.js +++ b/src/entity2diagram.test.js @@ -9,7 +9,7 @@ describe('Convert entity to diagram', () => { id: id(Number), stringTest: field(String), booleanTest: field(Boolean), - ArrayTest: field([String]), + arrayTest: field([String]), isExample: () => true }) @@ -47,6 +47,7 @@ describe('Convert entity to diagram', () => { assert.match(result, /Number id/) assert.match(result, /String stringTest/) assert.match(result, /Boolean booleanTest/) + assert.match(result, /String\[\] arrayTest/) assert.match(result, /isExample()/) })