Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests failing as of 4.9.1 #407

Open
skrivle opened this issue Mar 25, 2024 · 0 comments
Open

Unit tests failing as of 4.9.1 #407

skrivle opened this issue Mar 25, 2024 · 0 comments

Comments

@skrivle
Copy link

skrivle commented Mar 25, 2024

Hi 👋

First of all, thank you so much for the great work on emoji-picker-react 🙏 .

I wanted to report that we saw our unit tests fail when upgrading to 4.9.2. We believe the breaking change was introduced as part of 4.9.1. More specifically in the getLabelHight function here

Since the DEFAULT_LABEL_HEIGHT is now returned whenever no height greater than 0 is found, the function will always return 40 when running inside JSDOM. All other measurements (getBoundingClientRect, getBoundingClientRect, ...), however will return 0. This makes it so that no emoji is found when calling focusFirstVisibleEmoji.

We have a test that does something along these lines:

const searchBox = screen.getByRole('textbox', { name: 'Type to search for an emoji' });

await userEvent.type(searchBox, 'cat');
await userEvent.tab();
await userEvent.tab();
await userEvent.tab();
await userEvent.keyboard('{enter}');

expect(update).toHaveBeenCalledWIth(...)

We've currently fixed this by mocking getBoundingClientRect and getBoundingClientRect to return values in way so that focusFirstVisibleEmoji does return results. However, this is not very transparant and might easily break if the underlying implementation changes.

Though this is an issue that will only occur when running in JSDOM, I think more folks might run into this, so if there's a way to change the implementation to accommodate this, that'd be really great!

Thanks again for you work.

Regards,

Jelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant