Skip to content

🧪 Add tests for i18n pluralization and utilities - #81

Open
Matuyuhi wants to merge 2 commits into
mainfrom
test/i18n-plural-9366834780091891690
Open

Matuyuhi wants to merge 2 commits into
mainfrom
test/i18n-plural-9366834780091891690

Conversation

@Matuyuhi

Copy link
Copy Markdown
Owner

🎯 What: The testing gap addressed
Missing test coverage for src/shared/i18n.ts utility functions, specifically plural, t, and applyI18nSubs. This ensures translation substitution and pluralization logic handles localization edge cases correctly.

📊 Coverage: What scenarios are now tested

  • Tested applyI18nSubs with 0, 1, and multiple substitutions, plus out-of-bounds indices.
  • Tested t using mock fallback messages, including success cases with array substitutions, single integer substitutions, and fallback behavior for missing keys.
  • Tested plural for standard edge cases (count = 1 vs count != 1 like 0, 2, -1).
  • Tested plural automatically passing the count as default substitution.
  • Tested plural overriding default substitutions correctly when explicit substitution strings or arrays are passed.

✨ Result: The improvement in test coverage
The src/shared/i18n.ts file now has robust test coverage ensuring that our pluralization and translation interpolations logic behaves reliably in all identified edge cases.


PR created automatically by Jules for task 9366834780091891690 started by @Matuyuhi

Added comprehensive test coverage for `src/shared/i18n.ts`, specifically testing `applyI18nSubs`, `t`, and `plural` utilities. Covered substitution logic, missing keys, singular vs plural rules, and overriding default count substitutions.

Co-authored-by: matuyuhi <92073990+matuyuhi@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Fix the types passed in substitutions array for the i18n testing of `plural()`. `t()` expects strings, string arrays, numbers, or number arrays, but typescript validation of `(string | number)[]` triggered an issue due to how multiple elements type infer.

Used explicit strings `'1'` and `'3'` in the mock substitutions parameter array to resolve type compilation error (TS2322) running `bun run tsc`.

Co-authored-by: matuyuhi <92073990+matuyuhi@users.noreply.github.com>
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.

1 participant