Skip to content

[Feature]: Add unit tests for helper utilities #1781

Description

@SujalMahapatra

Feature/Project Proposal

Add comprehensive unit tests for the utility functions in frontend/src/utils/helper.js.

The module currently provides validateEmail and getInitials, but these functions do not have dedicated test coverage.

Problem Statement

The helper utilities are used throughout the frontend but currently lack dedicated unit tests.

Without tests, changes to email validation or initials generation could introduce regressions without being detected. Edge cases such as empty values, invalid email formats, whitespace, and titles containing multiple words should also be explicitly covered.

Proposed Solution

Create a Vitest unit test file for src/utils/helper.js.

The tests should cover:

  • Valid email addresses.
  • Invalid email addresses.
  • Empty, null, and non-string email inputs.
  • Titles with one word.
  • Titles with multiple words.
  • Titles containing leading/trailing whitespace.
  • Titles containing more than two words.
  • Empty or missing titles.
  • Correct uppercase initials generation.

Alternatives Considered

No changes to the existing implementation are proposed.

The goal is to add focused unit-test coverage around the current helper behavior without changing its functionality.

Benefits

  • Improves frontend test coverage.
  • Protects commonly used helper functions from regressions.
  • Documents the expected behavior of validateEmail and getInitials.
  • Covers important edge cases.
  • Makes future refactoring safer.

Priority

High

Additional Context

No response

Checklist

  • I have searched existing issues and discussions before creating this request.
  • I am willing to work on this feature if it is approved.

Metadata

Metadata

Labels

claimedThis issue has been claimed by a contributorenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions