-
-
Notifications
You must be signed in to change notification settings - Fork 2
Add CommonJS exports and tests for functional modules #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
There was a problem hiding this 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
ctcTargetis 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.
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.
…deRaccoons/WebTricks into CopyToClipboard-unit-tests
This pull request adds comprehensive unit tests for three modules:
CopyToClipboard,Marquee, andReadTime. 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
__tests__/CopyToClipboard.test.jsto cover initialization, clipboard copying, UI updates, and error handling for theCopyToClipboardmodule.__tests__/Marquee.test.jsto verify marquee initialization, scrolling behavior in both directions, resizing logic, and DOM manipulation for theMarqueemodule.__tests__/ReadTime.test.jsto check read-time calculation, suffix handling, and display logic for theReadTimemodule, including cases with no articles.