Emoji: Link Replacement (#36341)

This commit is contained in:
Echo 2025-10-06 11:31:10 +02:00 committed by GitHub
commit ffac4cb05f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 346 additions and 116 deletions

View file

@ -53,13 +53,19 @@ describe('html', () => {
it('calls onElement callback', () => {
const input = '<p>lorem ipsum</p>';
const onElement = vi.fn(
(element: HTMLElement, children: React.ReactNode[]) =>
React.createElement(element.tagName.toLowerCase(), {}, ...children),
const onElement = vi.fn<html.OnElementHandler>(
(element, props, children) =>
React.createElement(
element.tagName.toLowerCase(),
props,
...children,
),
);
html.htmlStringToComponents(input, { onElement });
expect(onElement).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ tagName: 'P' }),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
expect.objectContaining({ key: expect.any(String) }),
expect.arrayContaining(['lorem ipsum']),
{},
);
@ -71,6 +77,8 @@ describe('html', () => {
const output = html.htmlStringToComponents(input, { onElement });
expect(onElement).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ tagName: 'P' }),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
expect.objectContaining({ key: expect.any(String) }),
expect.arrayContaining(['lorem ipsum']),
{},
);