Skip to content

Commit f120b36

Browse files
test(css-helper): keep wildcard selector and adjust tests
1 parent 636b100 commit f120b36

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/tests/__fixtures__/curriculum-helper-css.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export const cssString = `:root {
4747
--window-color3: #d98cb3;
4848
--window-color4: #8cb3d9;
4949
}
50+
51+
* {
52+
box-sizing: border-box;
53+
}
54+
5055
body {
5156
height: 100vh;
5257
margin: 0;

packages/tests/css-helper.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ describe("css-help", () => {
2121
});
2222
});
2323
describe("getStyle", () => {
24-
it("should return null for wildcard selectors", () => {
25-
expect(t.getStyle("*")).toBeNull();
24+
it("should return a style for wildcard selector when present", () => {
25+
expect(t.getStyle("*")).toBeTruthy();
2626
});
27-
28-
it("should return null for compound wildcard selectors", () => {
29-
expect(t.getStyle("div > * > span")).toBeNull();
27+
it("should return null for selector not present in CSS", () => {
28+
expect(t.getStyle(".this-selector-does-not-exist")).toBeNull();
3029
});
3130
it("should return a non-empty ExtendedCSSStyleDeclaration object", () => {
3231
expect(t.getStyle(".bb1")).toBeTruthy();
@@ -42,9 +41,9 @@ describe("css-help", () => {
4241
expect(t.getStyleAny([".earth", ".sky"])?.length).toEqual(1);
4342
});
4443
it("should return null when none of the selectors match", () => {
45-
expect(t.getStyleAny([".sun", ".earth", ".moon"])).toBeNull();
44+
expect(t.getStyleAny([".sun", ".moon"])).toBeNull();
4645
});
47-
it("should ignore wildcard selectors inside getStyleAny", () => {
46+
it("should return style even if wildcard selector is present in the list", () => {
4847
expect(t.getStyleAny(["*", ".bb1"])).toBeTruthy();
4948
});
5049
});

0 commit comments

Comments
 (0)