-
Notifications
You must be signed in to change notification settings - Fork 9
/
ThemeProvider.test.tsx
79 lines (71 loc) · 2.4 KB
/
ThemeProvider.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { render, screen } from "@testing-library/react";
import ThemeProvider, { useTheme } from "./ThemeProvider";
function ExampleComponent() {
const { themeName } = useTheme();
return <div data-testid="themeName">{themeName}</div>;
}
describe("themeProvider", () => {
it("renders children with the provided themeName - classic", () => {
const themeName = "classic";
render(
<ThemeProvider themeName={themeName}>
<ExampleComponent />
</ThemeProvider>,
);
expect(screen.getByTestId("themeName")).toHaveTextContent(themeName);
});
it("renders children with the provided themeName - cambio", () => {
const themeName = "cambio";
render(
<ThemeProvider themeName={themeName}>
<ExampleComponent />
</ThemeProvider>,
);
expect(screen.getByTestId("themeName")).toHaveTextContent(themeName);
});
it("renders the correct classic styles", () => {
render(
<ThemeProvider themeName="classic">
<ExampleComponent />
</ThemeProvider>,
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-black: #000000;",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-white: #ffffff;",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-gray-10: rgba(203, 203, 203, 0.5);",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--elevation-400: 0px 16px 32px 0px #00000040;",
);
expect(screen.getByTestId("themeprovider-style")).not.toContainHTML(
"cambio",
);
});
it("renders the correct cambio styles", () => {
render(
<ThemeProvider themeName="cambio">
<ExampleComponent />
</ThemeProvider>,
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-black: #050500;",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-white: #ffffff;",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-gray-100: #faf4eb;",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML(
"--color-base-primary-100: #faf4eb;",
);
expect(screen.getByTestId("themeprovider-style")).not.toContainHTML(
"elevation",
);
expect(screen.getByTestId("themeprovider-style")).toContainHTML("cambio");
});
});