-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.test.tsx
47 lines (39 loc) · 1.29 KB
/
App.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
import React from "react";
import { screen, render } from "@testing-library/react";
import { Component } from "./Component";
import { ThemeProvider, Theme } from "theme-ui";
const theme: Theme = {
colors: {
background: "white",
text: "black",
primary: "tomato",
},
};
describe("describe", () => {
it.only("checked background should be tomato.", (done) => {
const dataTestId = "test-text";
const dataTestInputId = "test-input";
const dataTestContainerId = "test-container";
render(
<ThemeProvider theme={theme}>
<Component
checked={true}
{...{ "data-testid": dataTestContainerId }}
inputProps={{ "data-testid": dataTestInputId }}
textProps={{ "data-testid": dataTestId }}
/>
</ThemeProvider>
);
const input = screen.getByTestId(dataTestInputId);
expect(input).toHaveAttribute("checked", "");
const container = screen.getByTestId(dataTestInputId);
const getComputedCSS = (container.ownerDocument.defaultView as Window)
.getComputedStyle;
const css = getComputedCSS(container);
// console.log({ css });
console.log("dudee");
const text = screen.getByTestId(dataTestId);
expect(text).toHaveStyle(`background-color: ${theme.colors?.primary}`);
return done();
});
});