Skip to content

Commit

Permalink
Add boolean support. Fixes #164
Browse files Browse the repository at this point in the history
  • Loading branch information
blittle committed Dec 7, 2023
1 parent 125cc76 commit bbb0ca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/TreeView/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export const getAccessibleRange = ({
/**
* This is to help consumers to understand that we do not currently support metadata that is a nested object. If this is needed, make an issue in Github
*/
export type IFlatMetadata = Record<string, string | number | undefined | null>;
export type IFlatMetadata = Record<string, string | number | boolean | undefined | null>;

interface ITreeNode<M extends IFlatMetadata> {
id?: NodeId;
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/TreeViewMetadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ const initialTreeNode = {
name: "Fruits",
id: 54,
children: [
{ name: "Avocados", id: 98, metadata: { color: 'green' } },
{ name: "Bananas", id: 789, metadata: { color: 'yellow' } },
{ name: "Avocados", id: 98, metadata: { color: 'green', available: true } },
{ name: "Bananas", id: 789, metadata: { color: 'yellow', available: false } },
],
},
{
id: 888,
name: "Drinks",
children: [
{ name: "Apple Juice", id: 990, metadata: { color: 'yellow' } },
{ name: "Coffee", id: 9 , metadata: { color: 'brown' }},
{ name: "Apple Juice", id: 990, metadata: { color: 'yellow', available: true } },
{ name: "Coffee", id: 9 , metadata: { color: 'brown', available: true }},
{
id: 43,
name: "Tea",
children: [
{ name: "Black Tea", id: 4, metadata: { color: 'black' } },
{ name: "Green Tea", id: 44, metadata: { color: 'green' } },
{ name: "Black Tea", id: 4, metadata: { color: 'black', available: false } },
{ name: "Green Tea", id: 44, metadata: { color: 'green', available: false } },
{
id: 53,
name: "Matcha",
metadata: { color: 'green' },
children: [{ name: "Matcha 1", id: 2, metadata: { color: 'green' } }],
metadata: { color: 'green', available: true },
children: [{ name: "Matcha 1", id: 2, metadata: { color: 'green', available: false } }],
},
],
},
Expand Down Expand Up @@ -101,7 +101,7 @@ function TreeViewMetadata(props: TreeViewDataTypeProps) {
const thisNodesMetadata = nodeData.metadata;
if (thisNodesMetadata !== undefined) {
const node = nodes.find((x) => {
return x.innerHTML.includes(`${thisNodesMetadata.color}`)
return x.innerHTML.includes(`${thisNodesMetadata.color}`) && x.innerHTML.includes(`${thisNodesMetadata.available}`)
});
expect(node).toBeDefined;
} else {
Expand Down

0 comments on commit bbb0ca7

Please sign in to comment.