-
-
Notifications
You must be signed in to change notification settings - Fork 2
Feature adding tests to project #62
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 a Jest test suite for CookieConsent covering banner display, event wiring, cookie setting, script injection, and consent management. Updated CookieConsent.js to support module exports for test environments.
Added Jest tests for CountUp functionality, including initialization, counting logic, custom step, prefix/suffix, and edge cases. Updated CountUp.js to export CountUp and InitializeCountUp for test environments without affecting browser usage.
Added a comprehensive Jest test suite for FormCheck covering initialization, validation, error handling, reset, and various input types. Updated FormCheck.js to support CommonJS exports for test environments without affecting browser usage.
Adds a polyfill for HTMLElement.innerText in jsdom to mirror textContent behavior, ensuring compatibility with code that relies on innerText in Jest tests.
Added comprehensive Jest tests for CMSFilter functionality in __tests__/CMSFilter.test.js. Updated CMSFilter.js to export CMSFilter and InitializeCMSFilter for test environments, and fixed range filtering to use normalized dataset keys.
Added CommonJS export to FormatNumbers.js for testability. Introduced comprehensive Jest tests for NumberFormatter and InitializeFormatNumbers covering formatting styles, error handling, and multiple element scenarios.
Introduces a GitHub Actions workflow to run tests on push and pull request events. The workflow sets up Node.js, installs dependencies, runs Jest tests with coverage, uploads coverage artifacts, and appends a coverage summary to the job summary.
Exports CMSSelect and InitializeCMSSelect for CommonJS environments to support testing and bundlers. Adds comprehensive Jest tests for CMSSelect functionality and updates documentation to describe programmatic initialization.
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 multiple JavaScript modules in the codebase by implementing Jest-based unit tests. The changes enable testing in a Node.js/jsdom environment while maintaining browser compatibility.
- Adds test files for 6 modules: FormatNumbers, FormCheck, CountUp, CookieConsent, CMSSelect, and CMSFilter
- Implements CommonJS exports in all tested modules to enable importing in test environments
- Adds innerText polyfill in jest.setup.js for jsdom compatibility
- Creates GitHub Actions workflow for automated testing with coverage reporting
- Updates documentation for programmatic usage
Reviewed Changes
Copilot reviewed 9 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| jest.setup.js | Adds innerText polyfill for jsdom to mirror textContent behavior |
| docs/WebflowOnly/CMSSelect.md | Documents programmatic initialization option for testing/bundlers |
| tests/FormatNumbers.test.js | Comprehensive tests for number formatting with various styles and locales |
| tests/FormCheck.test.js | Tests form validation, error handling, and submission logic |
| tests/CountUp.test.js | Tests counter animation with custom steps, speeds, and targets |
| tests/CookieConsent.test.js | Tests cookie consent banner, category management, and script injection |
| tests/CMSSelect.test.js | Tests select element population from CMS data sources |
| tests/CMSFilter.test.js | Tests filtering, sorting, pagination, and advanced filtering features |
| Dist/WebflowOnly/CMSSelect.js | Adds CommonJS exports for testing without affecting browser usage |
| Dist/WebflowOnly/CMSFilter.js | Adds CommonJS exports and fixes range filtering dataset access |
| Dist/Functional/FormatNumbers.js | Adds CommonJS exports wrapped in try-catch |
| Dist/Functional/FormCheck.js | Adds CommonJS exports with aliased initializer function |
| Dist/Functional/CountUp.js | Adds CommonJS exports wrapped in try-catch |
| Dist/Functional/CookieConsent.js | Adds CommonJS exports for test environment compatibility |
| .github/workflows/tests.yml | Creates CI workflow for running tests with coverage reporting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces comprehensive automated tests for several key modules and adds a GitHub Actions workflow for continuous integration. The most important changes are the addition of test suites for
CMSFilter,CMSSelect,CookieConsent, andCountUp, which verify their core behaviors and edge cases, and the setup of a workflow to run these tests and report coverage.Automated Testing Enhancements:
__tests__/CMSFilter.test.jswith extensive tests for filtering, sorting, pagination, tag management, and advanced filtering in theCMSFiltermodule.__tests__/CMSSelect.test.jsto verify single/multiple select population, custom value handling, error logging, and fallback logic in theCMSSelectmodule.__tests__/CookieConsent.test.jsto test banner display, cookie setting, script injection, and consent management in theCookieConsentmodule.__tests__/CountUp.test.jsto test counter initialization, incrementing logic, prefix/suffix formatting, custom step handling, and edge cases in theCountUpmodule.Continuous Integration Setup:
.github/workflows/tests.ymlworkflow to run tests on push and pull requests, install dependencies, execute Jest tests with coverage, upload coverage artifacts, and summarize coverage in job output.