Skip to content

test: add unit tests for formatTime helper - #2412

Open
SanjanaGadamsetty wants to merge 1 commit into
Canopus-Labs:mainfrom
SanjanaGadamsetty:test/typing-speed-format-time
Open

SanjanaGadamsetty wants to merge 1 commit into
Canopus-Labs:mainfrom
SanjanaGadamsetty:test/typing-speed-format-time

Conversation

@SanjanaGadamsetty

@SanjanaGadamsetty SanjanaGadamsetty commented Nov 13, 2026 •

Copy link
Copy Markdown

Summary

  • Added unit tests for the existing formatTime helper.
  • Covered zero seconds, single-digit seconds, exact minutes, and mixed minute-second values.
  • Verified the expected MM:SS time formatting.

Test Cases

Input Expected Output
0 00:00
9 00:09
60 01:00
125 02:05

Testing

  • Run npm test -- --run from the frontend directory.

Related Issue

Closes #2411

Added tests for the formatTime function to validate correct time formatting.
@github-actions

Copy link
Copy Markdown

Thank you for submitting your pull request, @SanjanaGadamsetty! 🙌
We'll review it as soon as possible.
If there are any specific instructions or feedback regarding your PR, we'll provide them here.
Thanks again for your contribution to our project! 😊

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The unit test file imports formatTime and adds assertions for its MM:SS output at 0, 9, 60, and 125 seconds.

Changes: formatTime test coverage

Layer / File(s) Summary
Add formatTime assertions
frontend/src/components/TypingSpeedGame.unit.test.js
The test file imports formatTime and checks the expected zero-padded MM:SS output for four inputs.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: aasritha-sure

Merge Risk: Minimal · up to 4fcb5

This change adds tests for the time formatting helper and does not alter production behavior. There is no actionable merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "test: add unit tests for formatTime helper" matches the changeset. The PR adds unit test assertions for the existing formatTime helper, covering inputs 0, 9, 60, and 125 with expected MM:SS…
Linked Issues check Passed Issue #2411 requires unit tests in TypingSpeedGame.unit.test.js for the existing formatTime helper, covering 0 → 00:00, 9 → 00:09, 60 → 01:00, and 125 → 02:05. The PR diff adds the formatTime import a…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes only frontend/src/components/TypingSpeedGame.unit.test.js. The changes are the formatTime import, the reformatted import block, and the new test case f…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "test: add unit tests for formatTime helper" matches the changeset. The PR adds unit test assertions for the existing formatTime helper, covering inputs 0, 9, 60, and 125 with expected MM:SS output. The title is concise and names the primary change.

Full details: Linked Issues check

Explanation

Issue #2411 requires unit tests in TypingSpeedGame.unit.test.js for the existing formatTime helper, covering 0 → 00:00, 9 → 00:09, 60 → 01:00, and 125 → 02:05. The PR diff adds the formatTime import and a new it("formats time correctly") block that asserts exactly these four cases. At the reviewed head, formatTime in frontend/src/components/typingSpeedHelpers.js returns Math.floor(totalSeconds / 60) and totalSeconds % 60, each zero-padded to two digits. Tracing the four inputs through this code yields the expected strings. The test run (npm test -- --run) is unchecked in the PR description, so the test pass was not observed. The static evidence supports compliance.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes only frontend/src/components/TypingSpeedGame.unit.test.js. The changes are the formatTime import, the reformatted import block, and the new test case for the four cases in #2411. The diff also adds one whitespace-only line before the new test. This is cosmetic and does not add scope. No production code changes are present.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8912d5e0-c0e6-4b7e-9d9f-7d742e7c1744
Commits

Reviewing files that changed from the base of the PR and between a8d14cf and 4fcb5b9.

Files selected for processing: 1

  • frontend/src/components/TypingSpeedGame.unit.test.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added the merge ready PR is mergeable and has no conflicts label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready PR is mergeable and has no conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for formatTime helper

1 participant