Skip to content

test: add unit tests for I18nContext defaults and language switching#447

Merged
utksh1 merged 1 commit into
utksh1:mainfrom
HarshParmar029:feat/i18n-context-unit-tests
May 31, 2026
Merged

test: add unit tests for I18nContext defaults and language switching#447
utksh1 merged 1 commit into
utksh1:mainfrom
HarshParmar029:feat/i18n-context-unit-tests

Conversation

@HarshParmar029
Copy link
Copy Markdown
Contributor

Closes #77

Changes

  • Added unit tests for frontend/src/components/I18nContext.tsx
  • File: frontend/testing/unit/components/I18nContext.test.tsx

Tests added (9 tests)

  • Default locale is en
  • Valid nested key resolves correctly
  • Invalid key returns path as fallback
  • setLocale function is exposed in context
  • Switching to French updates locale
  • Switching to Hindi updates locale
  • Locale is always a string (regression guard)
  • t is always a function (regression guard)
  • useTranslation throws outside provider

Verification

npm run test → 207 passed (23 files)
image

@HarshParmar029
Copy link
Copy Markdown
Contributor Author

Hi @utksh1! I've opened PR #447 for this issue. All 6 CI checks are passing. Would appreciate a review when you get a chance.

@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label area:frontend Frontend React/UI work labels May 31, 2026
Copy link
Copy Markdown
Owner

@utksh1 utksh1 left a comment

Choose a reason for hiding this comment

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

Looks good: focused I18nContext unit coverage for defaults, translation lookup, locale switching, and provider misuse; checks are green.

@utksh1 utksh1 added the gssoc:approved Admin validation: approved for GSSoC scoring label May 31, 2026
@utksh1 utksh1 merged commit 766caeb into utksh1:main May 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend React/UI work gssoc:approved Admin validation: approved for GSSoC scoring level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GOOD FIRST ISSUE] Add unit tests for I18nContext defaults and language switching

2 participants