Skip to content
This repository has been archived by the owner on Nov 12, 2021. It is now read-only.

Cross-platform Picker component with real i18n in tests #44

Merged
merged 9 commits into from Jul 8, 2020

Conversation

AlanSl
Copy link
Member

@AlanSl AlanSl commented Jul 8, 2020

  • Fixes As a user I want the iOS example picker to be properly aligned #33 (picker display glitch on iOS)
  • Splits the generic cross-platform picker out from the language switcher to make it re-usable
  • Swaps react-native's deprecated Picker for the officially-endorsed @react-native-community/picker which is supported in Expo SDK 38
  • Gets i18n working in tests so functions like changeLanguage really do change the language (using i18n's cimode, so t continues to return the stable key in tests rather than the more-changable translated text)
  • Gives the generic PickerSheet a generic "did the function call" unit test and the LanguageSwitcher a real test asserting that components with useTranslation do re-render on changes with a new language
  • Add note to readme about i18n in tests

Tested on Web, simulated iOS and real Android. Fixed iOS view:

@AlanSl AlanSl requested review from andreaforni and kurdin July 8, 2020 07:38
Copy link
Contributor

@andreaforni andreaforni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @AlanSl, looks good to me. I've just left a non-blocking comment about test's name convention.

};

describe('Picker Sheet', () => {
it('value change calls onValueChange function', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use the it() function to define a test, I usually change the test's name/description to include it as the subject of the sentence, to express the intention of the test (like in the e2e test: it('changes the app language')).

Another option, would be leave the name/description as is, and use test() instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, consistency is good, I'll change it

@AlanSl AlanSl merged commit c1f8b05 into master Jul 8, 2020
AlanSl added a commit that referenced this pull request Jul 10, 2020
* Install @react-native-community/picker, run expo update

Also add @react-native-community/picker to modules Jest must transpile

* Split cross-platform picker and language-selector

* Use cross-platform picker in ListView

* Update tests to use real i18n and web picker

* Explicitly include i18n in app

Previously it seemed to be included indirectly through subcomponents, which risks timing issues

* Update e2e test, using same test ID as unit tests

* Add readme note on using i18n in tests

* Write test name as "It {does thing}" sentence

* Also write other test name as "It {does thing}"
@katie-roberts katie-roberts deleted the fix/pickers branch November 12, 2020 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants