mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 12:09:14 +08:00
ec13e824be
* feat: v5 shadow * chore: color lint * test: fix test case
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { Theme } from '@ant-design/cssinjs';
|
|
import * as React from 'react';
|
|
import { render, renderHook } from '../../../tests/utils';
|
|
import ConfigProvider from '../../config-provider';
|
|
import theme from '../export';
|
|
|
|
const { useToken } = theme;
|
|
|
|
describe('Theme', () => {
|
|
it('useTheme', () => {
|
|
const { result } = renderHook(() => useToken());
|
|
|
|
expect(result.current!.theme instanceof Theme).toBeTruthy();
|
|
expect(result.current!.hashId).toBeFalsy();
|
|
expect(result.current!.token).toEqual(
|
|
expect.objectContaining({
|
|
colorPrimary: '#1677ff',
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('ConfigProvider with seed', () => {
|
|
const Demo = React.forwardRef((_, ref: any) => {
|
|
const themeObj = useToken();
|
|
ref.current = themeObj;
|
|
return null;
|
|
});
|
|
|
|
const themeRef = React.createRef<ReturnType<typeof useToken>>();
|
|
render(
|
|
<ConfigProvider
|
|
theme={{
|
|
token: {
|
|
colorPrimary: '#ff0000',
|
|
},
|
|
}}
|
|
>
|
|
<Demo ref={themeRef} />
|
|
</ConfigProvider>,
|
|
);
|
|
|
|
expect(themeRef.current!.token).toEqual(
|
|
expect.objectContaining({
|
|
colorPrimary: '#ff0000',
|
|
colorPrimaryHover: '#ff3029', // It's safe to modify if theme logic changed
|
|
}),
|
|
);
|
|
});
|
|
});
|