Skip to content

Improve test coverage from 92.3% to 100% statements#60

Merged
gfyoung merged 1 commit into
masterfrom
copilot/improve-test-coverage
Apr 5, 2026
Merged

Improve test coverage from 92.3% to 100% statements#60
gfyoung merged 1 commit into
masterfrom
copilot/improve-test-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

Several code paths in basic-tts.js had no test coverage: the checkVoices attempts normalization logic, the speak() null-utterance rejection path, and the AMD define export block.

New test cases

checkVoices attempts normalization (lines 132, 136)

  • String attempts (e.g. "2") → parsed via parseInt
  • Non-numeric string (e.g. "abc") → parseInt yields NaN → resets to default
  • Negative number → resets to default

speak() with null utterance (line 214)

  • Voices available but voice prop doesn't match any → getUtterance returns null → rejects with "invalid voice" message

AMD define block (lines 266–271)

  • Mocks global.define with define.amd = true via jest.resetModules() to force re-evaluation of the module-level guard
  • Verifies both define("basic-tts", ...) and anonymous define(...) are called with correct factory functions
  • Verifies define is not called when define.amd is absent

Coverage delta

Metric Before After
Statements 92.3% 100%
Functions 90.9% 100%
Lines 92.3% 100%
Branches 80.4% 91.3%

Remaining uncovered branches (lines 40–41, 258) are environment-detection guards (typeof window for browser context, Node module.exports false branch) not reachable in Jest.

Copilot AI requested a review from gfyoung April 5, 2026 00:27
@gfyoung gfyoung marked this pull request as ready for review April 5, 2026 00:31
@gfyoung gfyoung merged commit 31b2d62 into master Apr 5, 2026
4 of 10 checks passed
@gfyoung gfyoung deleted the copilot/improve-test-coverage branch April 5, 2026 00:31
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.

2 participants