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

Add tests for select #201

Merged
merged 3 commits into from
Nov 24, 2022
Merged

Conversation

Kzoeps
Copy link
Contributor

@Kzoeps Kzoeps commented Nov 20, 2022

  1. Created a test to check if select is rendered
  2. Created a test to see if the initial value is set on render. Did this using a check to see if the selected value is initially present or not. Couldn't use value since antd renders Select as input with combobox and doesn't update the value
  3. Created a test to see if the value changes when the user clicks on a different option. Since fireEvent.change does not seem to work, I used mouseDown to first open the select and then click to select an option. antd renders the options as span so I was not able to use option.selected. Furthermore I used the check of toBeGreaterThan since I couldnt find a way to close the dropdown.

@jannikbuschke lmk what if you have any feedback or changes to be made

Referenced these links while coming up with the third test:

  1. Impossible to expand Select component dropdown programatically ant-design/ant-design#22074 (comment)
  2. Cannot test Select with react testing library after upgrading to v4 ant-design/ant-design#23009

@jannikbuschke jannikbuschke merged commit 4563e51 into jannikbuschke:master Nov 24, 2022
@jannikbuschke
Copy link
Owner

looks cool 👍
@all-contributors add @Kzoeps for test

@allcontributors
Copy link
Contributor

@jannikbuschke

I've put up a pull request to add @Kzoeps! 🎉

@Kzoeps Kzoeps deleted the tests-select branch November 24, 2022 16:56
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

Successfully merging this pull request may close these issues.

2 participants