[Autocomplete] Warn when using wrong getOptionSelected#19699
Conversation
|
No bundle size changes comparing 5ed8d0a...0bd00e0 |
|
@ahmad-reza619 Thanks, it would be perfect with a test case. |
|
@oliviertassinari alright, will do |
|
I'm a bit confused as to where to put the test case, Autocomplete or useAutoComplete? 🤔 sorry btw i'm new when it comes to testing |
|
@ahmad-reza619 Do you think that you could add a test case? :) |
i'll do but it's kinda hard for me 😢 i don't understand about testing and this lib surely huge😅 i would like some guidance 😄 |
|
do i have to only give getOptionSelected props in testing 🤔 and also am i have to use stub or spy to replicate it's functionality. 😓 sorry btw still confused here |
Try writing a component that passes props to Autocomplete so that this warning is triggered. For how to assert on the warning you could use https://github.com/mui-org/material-ui/blob/f57707d1c328d22e2ce46dd12f08164271534f90/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js#L84-L110 as an inspiration. |
|
@eps1lon but this one a little bit complex i think 🤔 because you have to make a component to assert this behavior. and there's no example that i can use 😓 |
oliviertassinari
left a comment
There was a problem hiding this comment.
Don't worry, writing a test case can be challenging. It requires a deep understanding of what's going on. I have added one, I think that we can move forward :)
Thank you so much for the help, but it's fail? is it because of the test 🤔 ? |
|
Azure pipeline has been unreliable since yesterday, I don't know if the issue is on our side, there are out of memory crashes. Reruning solves the problem. To monitor. Thanks. |
|
@oliviertassinari |
Close #19595
I followed what suggested in the issue, but i suggest to change the props
getOptionSelectedto be more precise. It can be as what suggested by @oliviertassinari likeoptionEqualValue, or my recommendation isgetSelectedOption. but it's up to you guys (actually i had a little hard time thinking what this props does, but i don't know if it's will become a breaking change 🤔 )i used array filter here. it does support all kinds of browsers except IE 6-8 based on this report
Have a nice day 😄