generated from react-component/trigger
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.test.tsx
64 lines (60 loc) · 1.64 KB
/
index.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
import { StyleProvider } from '@ant-design/cssinjs';
import { extractStyle } from '../src/index';
import { ConfigProvider } from 'use-testing-antd';
const testGreenColor = '#008000';
jest.mock('antd', () => jest.requireActual('use-testing-antd'));
beforeEach(() => jest.clearAllMocks());
describe('Static-Style-Extract', () => {
it('should extract static styles', () => {
const cssText = extractStyle();
expect(cssText).not.toContain(testGreenColor);
expect(cssText).toMatchSnapshot();
});
it('should extract static styles with customTheme', () => {
const cssText = extractStyle((node) => (
<ConfigProvider
theme={{
token: {
colorPrimary: testGreenColor,
},
}}
>
{node}
</ConfigProvider>
));
expect(cssText).toContain(testGreenColor);
expect(cssText).toMatchSnapshot();
});
it('with custom hashPriority', () => {
const cssText = extractStyle(
(node) => (
<StyleProvider hashPriority='high'>
<ConfigProvider
theme={{
token: {
colorPrimary: testGreenColor,
},
}}
>
{node}
</ConfigProvider>
</StyleProvider>
)
);
expect(cssText).toContain(testGreenColor);
expect(cssText).not.toContain(':where');
expect(cssText).toMatchSnapshot();
const cssText2 = extractStyle((node) => (
<ConfigProvider
theme={{
token: {
colorPrimary: testGreenColor,
},
}}
>
{node}
</ConfigProvider>
));
expect(cssText2).toContain(':where');
});
});