Skip to content

Conversation

@JorchCortez
Copy link
Contributor

This pull request adds comprehensive unit tests for three modules: CopyToClipboard, Marquee, and ReadTime. These tests use the Jest framework with a jsdom environment to simulate browser behavior and verify correct functionality, edge cases, and DOM interactions. The new tests improve confidence in the modules' reliability and help ensure future changes do not break existing features.

New Test Coverage

  • Added __tests__/CopyToClipboard.test.js to cover initialization, clipboard copying, UI updates, and error handling for the CopyToClipboard module.
  • Added __tests__/Marquee.test.js to verify marquee initialization, scrolling behavior in both directions, resizing logic, and DOM manipulation for the Marquee module.
  • Added __tests__/ReadTime.test.js to check read-time calculation, suffix handling, and display logic for the ReadTime module, including cases with no articles.

Added CommonJS export support to CopyToClipboard, Marquee, and ReadTime modules for testability. Introduced comprehensive Jest test suites for each module to verify initialization, behavior, and edge cases in a jsdom environment.
Copilot AI review requested due to automatic review settings November 8, 2025 02:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive test coverage for three functional modules (ReadTime, Marquee, and CopyToClipboard) and includes a bug fix for null target handling in the CopyToClipboard module.

  • Adds Jest test suites with multiple test cases for each module covering various scenarios and edge cases
  • Exports classes and initialization functions from each module to enable testing in Node.js environments
  • Fixes a potential null reference error when ctcTarget is missing in CopyToClipboard

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
__tests__/ReadTime.test.js New test suite covering read time calculation scenarios including edge cases for sub-minute, one-minute, and multi-minute content
__tests__/Marquee.test.js New test suite validating marquee initialization, scrolling behavior in both directions, element cycling, and resize handling
__tests__/CopyToClipboard.test.js New test suite testing clipboard copy functionality, text updates, class toggling, and error handling for missing elements
Dist/Functional/ReadTime.js Adds CommonJS module exports wrapped in try-catch for test environment compatibility
Dist/Functional/Marquee.js Adds CommonJS module exports wrapped in try-catch for test environment compatibility
Dist/Functional/CopyToClipboard.js Adds null check for ctcTarget to prevent errors and exports module for testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JorchCortez and others added 4 commits November 7, 2025 21:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Added safety guards to Marquee's fillContainer to prevent infinite loops when element sizes cannot be measured. Updated tests to proactively stop marquee intervals and drain timers, and added a global Jest setup file to increase timeouts and polyfill animation frame methods for jsdom. Configured Jest to use the setup file and increased default test timeout.
@JorchCortez JorchCortez merged commit 407b384 into main Nov 8, 2025
1 check passed
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