Skip to content

Commit

Permalink
feat(treemap): add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Jan 2, 2022
1 parent ba6071a commit 64628e1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 343 deletions.
3 changes: 3 additions & 0 deletions packages/treemap/src/TreeMapHtmlNode.tsx
Expand Up @@ -23,6 +23,7 @@ const NonMemoizedTreeMapHtmlNode = <Datum extends object>({

return (
<animated.div
data-testid={`node.${node.id}`}
id={node.path.replace(/[^\w]/gi, '-')}
style={{
boxSizing: 'border-box',
Expand Down Expand Up @@ -56,6 +57,7 @@ const NonMemoizedTreeMapHtmlNode = <Datum extends object>({
/>
{showLabel && (
<animated.span
data-testid={`label.${node.id}`}
style={{
...theme.labels.text,
position: 'absolute',
Expand Down Expand Up @@ -83,6 +85,7 @@ const NonMemoizedTreeMapHtmlNode = <Datum extends object>({
)}
{showParentLabel && (
<animated.span
data-testid={`parentLabel.${node.id}`}
style={{
...theme.labels.text,
position: 'absolute',
Expand Down
3 changes: 3 additions & 0 deletions packages/treemap/src/TreeMapNode.tsx
Expand Up @@ -24,6 +24,7 @@ const NonMemoizedTreeMapNode = <Datum extends object>({
return (
<animated.g transform={svgNodeTransform(animatedProps.x, animatedProps.y)}>
<animated.rect
data-testid={`node.${node.id}`}
width={to(animatedProps.width, v => Math.max(v, 0))}
height={to(animatedProps.height, v => Math.max(v, 0))}
fill={node.fill ? node.fill : animatedProps.color}
Expand All @@ -37,6 +38,7 @@ const NonMemoizedTreeMapNode = <Datum extends object>({
/>
{showLabel && (
<animated.text
data-testid={`label.${node.id}`}
textAnchor="middle"
dominantBaseline="central"
style={{
Expand All @@ -56,6 +58,7 @@ const NonMemoizedTreeMapNode = <Datum extends object>({
)}
{showParentLabel && (
<animated.text
data-testid={`parentLabel.${node.id}`}
dominantBaseline="central"
style={{
...theme.labels.text,
Expand Down

0 comments on commit 64628e1

Please sign in to comment.