Skip to content
4 changes: 4 additions & 0 deletions packages/tests/__fixtures__/curriculum-helper-css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ body {
}
.card:hover {
background-color: khaki;
}
span[class~="one"] *:first-of-type {
background-image: linear-gradient(#f93, #f93);
border-color: #d61;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please do not change the current existing strings, the current tests are based on these and changing them could interfere, if you need new css, create a new string

Copy link
Author

Choose a reason for hiding this comment

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

Thankyou for correcting me I will ensure I follow each command.I appreciate the community support

Copy link
Author

Choose a reason for hiding this comment

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

please do not change the current existing strings, the current tests are based on these and changing them could interfere, if you need new css, create a new string
I added new strings without modifying existing ones

Copy link
Contributor

Choose a reason for hiding this comment

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

the change to the existing string is still here

Copy link
Author

Choose a reason for hiding this comment

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

have a check I fixed

`;

Expand Down
32 changes: 32 additions & 0 deletions packages/tests/curriculum-helper.test.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

the changes to this file are only some empty lines added, please revert

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import React from "react";
import ReactDOM from "react-dom/client";

import cssTestValues from "./__fixtures__/curriculum-helper-css";
import { cssString } from "./__fixtures__/curriculum-helper-css";
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary to add the second import, it's already included in the first one

Copy link
Author

Choose a reason for hiding this comment

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

I revised it

import htmlTestValues from "./__fixtures__/curriculum-helpers-html";
import jsTestValues from "./__fixtures__/curriculum-helpers-javascript";
import whiteSpaceTestValues from "./__fixtures__/curriculum-helpers-remove-white-space";

import * as helper from "./../helpers/lib/index";
import { CSSHelp } from "./../helpers/lib/index";
Copy link
Contributor

Choose a reason for hiding this comment

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

it is not necessary to add the new import, the first one is importing everything fron the same file

Copy link
Author

Choose a reason for hiding this comment

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

I fixed it


const { stringWithWhiteSpaceChars, stringWithWhiteSpaceCharsRemoved } =
whiteSpaceTestValues;
Expand Down Expand Up @@ -862,3 +865,32 @@ describe("permutateRegex", () => {
expect(regex.test(`'b" === a`)).toBe(false);
});
});
describe("CSSHelp – universal selector handling", () => {
beforeEach(() => {
const style = document.createElement("style");
style.className = "fcc-injected-styles";
style.textContent = cssString;
document.head.appendChild(style);
});

afterEach(() => {
document.head.innerHTML = "";
});

it("should return styles for selectors containing a universal selector", () => {
const cssHelp = new CSSHelp(document);

const style = cssHelp.getStyle('span[class~="one"] *:first-of-type');

expect(style).not.toBeNull();
expect(style?.getPropVal("border-color")).toBe("#d61");
});

it("should return null for selectors that do not exist", () => {
const cssHelp = new CSSHelp(document);

const style = cssHelp.getStyle("div.non-existent-selector");

expect(style).toBeNull();
});
});