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

Improve language list prioritization #3293

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

Tak
Copy link
Collaborator

@Tak Tak commented Feb 10, 2023

Ensures that all of (language of the post being replied to, default post language, configured app languages, configured system languages) are prioritized when constructing the language list for composing, regardless of whether any of those are languages android knows about.

Partially addresses #3277


@Test
fun emptyInitialLanguagesAreDropped() {
val languages = getMockedInitialLanguages(arrayOf("", "", "fr", "", "kab", ""))
Copy link
Collaborator

Choose a reason for hiding this comment

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

(curiosity)

Why are there empty languages?

Or I have seen null checks for locales in lists?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default post language and reply language can both be empty in normal usage

@Test
fun initialLanguagesContainReplySelectedAppAndSystem() {
val expectedLanguages = arrayOf<String?>("yi", "tok", "da", "fr", "sv", "kab")
val languages = getMockedInitialLanguages(expectedLanguages)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't a test simply call the normal method with some test data?

(One wonders what is tested about a mocked list.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is a wrapper that mocks the response for querying the configured app and system languages, so that:

  • the tests don't accidentally rely on whatever values robolectric returns
  • we can verify the behavior of the code when it returns certain types of values

@connyduck connyduck merged commit f2b0719 into tuskyapp:develop Feb 25, 2023
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.

3 participants