Skip to content

Commit cdd30f3

Browse files
committed
fix tests
1 parent 69455eb commit cdd30f3

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/nthul/src/server/server-target/server-target.test.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cleanup, render, screen } from "@testing-library/react";
22
import { afterEach, describe, test } from "vitest";
3-
import { ServerTarget } from "./server-target";
43
import { DEFAULT_ID } from "../../constants";
4+
import { ServerTarget } from "./server-target";
55

66
describe("server-target", () => {
77
afterEach(cleanup);
@@ -25,6 +25,23 @@ describe("server-target", () => {
2525
},
2626
};
2727
render(<ServerTarget />);
28-
expect(screen.getByTestId("server-target").className).toBe(`th-${THEME} ${COLOR_SCHEME}`);
28+
expect(screen.getByTestId("server-target").className).toBe(`th-${THEME} ${COLOR_SCHEME} `);
29+
});
30+
31+
test("test classes from styles", ({ expect }) => {
32+
const THEME = "my-theme";
33+
const COLOR_SCHEME = "dark";
34+
globalThis.cookies = {
35+
[DEFAULT_ID]: {
36+
value: `${THEME},${COLOR_SCHEME}`,
37+
},
38+
};
39+
const styles = {
40+
[THEME]: `moduled-${THEME}`,
41+
dark: `moduled-dark`,
42+
light: `moduled-light`,
43+
};
44+
render(<ServerTarget styles={styles} />);
45+
expect(screen.getByTestId("server-target").className).toBe(`th-${styles[THEME]} ${styles[COLOR_SCHEME]} `);
2946
});
3047
});

lib/nthul/src/server/server-target/server-target.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function ServerTarget({ tag, targetId, styles }: ServerTargetProps) {
3636
if (styles) {
3737
theme = styles[theme];
3838
cs = styles[cs];
39-
specificity = styles[specificity];
39+
specificity = styles[specificity] ?? "";
4040
}
4141

4242
const cls = `th-${theme} ${cs} ${specificity}`;

0 commit comments

Comments
 (0)