Skip to content

test: Add Vitest unit tests for location-detector and country-flags helpers #232

Closed

Description

@O2sa

The geo utility module (src/lib/geo/location-detector.ts and src/lib/geo/country-flags.ts) maps user location strings to normalized country slugs and ISO flag codes using regex keyword matching, but currently lacks unit test coverage.

Motivation

Testing country normalization ensures regex boundary matching does not fail or produce false positives for similar words.

Tasks

  • Create src/lib/geo/tests/location-detector.test.ts.
  • Test exact match locations (e.g., 'Egypt' -> 'egypt', 'Germany' -> 'germany', 'Tokyo, Japan' -> 'japan').
  • Test word boundary handling to ensure substrings don't falsely match (e.g., words containing country substrings).
  • Test edge cases: null, empty string, special characters, whitespace.
  • Test getCountryCode in country-flags.ts for valid and unknown slugs.
  • Run pnpm test and verify all tests pass.

Tip

🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨

Activity

  1. Ghifariezra commented on Oct 11, 2026

    @Ghifariezra
    Contributor

    assign me, i would like to take this one

  2. github-actions commented on Oct 11, 2026

    @github-actions

    🎉 Issue assigned to @Ghifariezra! Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions