Skip to content

Comments

fix(curriculum):Add tests for universal selector in CSSHelp#562

Closed
Iyeroo wants to merge 1 commit intofreeCodeCamp:mainfrom
Iyeroo:Iyeroo-patch-1
Closed

fix(curriculum):Add tests for universal selector in CSSHelp#562
Iyeroo wants to merge 1 commit intofreeCodeCamp:mainfrom
Iyeroo:Iyeroo-patch-1

Conversation

@Iyeroo
Copy link

@Iyeroo Iyeroo commented Jan 31, 2026

fix(curriculum):Added tests for the universal selector functionality in CSSHelp, including cases for existing and non-existent selectors.

Checklist:

Closes #64218

This test file verifies the behavior of the CSSHelp class with respect to universal selectors (*).

Specifically, it tests that:

  1. CSS rules containing universal selectors are only matched when explicitly requested.

    • Example: A rule like span[class~="one"] *:first-of-type should match only when the exact selector is requested via getStyle.
  2. Non-existent or disallowed selectors return null as expected.

Implementation notes:

  • We mock the Document object to simulate a style sheet containing a universal selector rule.
  • We define global.CSSRule to allow TypeScript compilation in a Node environment, since CSSRule is normally a browser global.
  • getPropVal is verified to ensure that the helper method added by getStyle returns correct CSS property values.
  • No real DOM or browser is used; the tests run entirely in Node.

These tests ensure that the fix preventing implicit matching of universal selectors works correctly.

Added tests for the universal selector functionality in CSSHelp, including cases for existing and non-existent selectors.
@majestic-owl448
Copy link
Contributor

majestic-owl448 commented Feb 1, 2026

please make these changes in #561

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