Skip to content

Commit

Permalink
fix(entity2diagram): fix display of Array Fields in HerbsShelf
Browse files Browse the repository at this point in the history
fixes a bug where array fields in HerbsShelf were incorrectly displayed as 'undefined'.

fix #6
  • Loading branch information
vitorgamer58 committed Jul 1, 2023
1 parent 642f765 commit 1af4914
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/entity2diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/entity2diagram.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down Expand Up @@ -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()/)
})

Expand Down

0 comments on commit 1af4914

Please sign in to comment.