mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
f3f1dbf1b1
* chore: move in * wip: refactor the structure of design token * refactor: merge override * chore: mv in * chore: fix ts * chore: tmp all * chore: comment * chore: comment * chore: use variables * fix: compile error Co-authored-by: arvinxx <arvinx@foxmail.com>
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import ConfigProvider from '..';
|
|
import Button from '../../button';
|
|
|
|
describe('ConfigProvider.DynamicTheme', () => {
|
|
beforeEach(() => {
|
|
Array.from(document.querySelectorAll('style')).forEach(style => {
|
|
style.parentNode?.removeChild(style);
|
|
});
|
|
});
|
|
|
|
it('customize primary color', () => {
|
|
mount(
|
|
<ConfigProvider
|
|
theme={{
|
|
token: {
|
|
colorPrimary: '#f00',
|
|
},
|
|
}}
|
|
>
|
|
<Button />
|
|
</ConfigProvider>,
|
|
);
|
|
|
|
const dynamicStyles = Array.from(document.querySelectorAll('style[data-css-hash]'));
|
|
|
|
expect(
|
|
dynamicStyles.some(style => {
|
|
const { innerHTML } = style;
|
|
return (
|
|
innerHTML.includes('.ant-btn-primary') && innerHTML.includes('background-color:#f00')
|
|
);
|
|
}),
|
|
).toBeTruthy();
|
|
});
|
|
|
|
it('not crash on null token', () => {
|
|
expect(() => {
|
|
mount(
|
|
<ConfigProvider
|
|
theme={{
|
|
token: null as any,
|
|
}}
|
|
/>,
|
|
);
|
|
}).not.toThrow();
|
|
});
|
|
});
|