Skip to content

Commit

Permalink
Избавиться от проверки дочерних элементов в интерактивном изображении (
Browse files Browse the repository at this point in the history
…#300)

* #299 Избавиться от проверки дочерних элементов в интерактивном изображении
  • Loading branch information
qoudo authored Jan 15, 2025
1 parent 5828d63 commit 376f811
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ describe('InteractiveImage', () => {
);
}).toThrow();
});

it('should render points in the wrapper', () => {
const { queryAllByTestId } = render(
<InteractiveImage>
<Parts.Image src='https://www.images.com/123' />
<div data-testid='wrapper'>
<Parts.Point role='button' x={1} y={2} />
</div>
</InteractiveImage>,
);

expect(queryAllByTestId('interactive-image:image')).toHaveLength(1);
expect(queryAllByTestId('wrapper')).toHaveLength(1);
expect(queryAllByTestId('interactive-image:point')).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ export const InteractiveImage = forwardRef<HTMLDivElement, InteractiveImageProps

return (
<div ref={ref} className={rootClassName} {...rest} data-testid={testId}>
{Children.toArray(children).filter(
child =>
isValidElement(child) &&
(child.type === ImageAnchor || child.type === Image || child.type === Point),
)}
{Children.toArray(children).filter(child => isValidElement(child))}
</div>
);
},
Expand Down

0 comments on commit 376f811

Please sign in to comment.