mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 20:43:11 +08:00
fix: component token should work (#45721)
This commit is contained in:
parent
b99902ab76
commit
c3a63a9927
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable jsx-a11y/control-has-associated-label */
|
/* eslint-disable jsx-a11y/control-has-associated-label */
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs';
|
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs';
|
||||||
import message from '..';
|
import message from '..';
|
||||||
@ -271,4 +271,32 @@ describe('message.hooks', () => {
|
|||||||
const styleText = extractStyle(cache, true);
|
const styleText = extractStyle(cache, true);
|
||||||
expect(styleText).not.toContain('.ant-message');
|
expect(styleText).not.toContain('.ant-message');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('component fontSize should work', () => {
|
||||||
|
const Demo = () => {
|
||||||
|
const [api, holder] = message.useMessage();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
api.info({
|
||||||
|
content: <div />,
|
||||||
|
className: 'fontSize',
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfigProvider theme={{ components: { Message: { fontSize: 20 } } }}>
|
||||||
|
{holder}
|
||||||
|
</ConfigProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
render(<Demo />);
|
||||||
|
|
||||||
|
const msg = document.querySelector('.fontSize');
|
||||||
|
|
||||||
|
expect(msg).toBeTruthy();
|
||||||
|
expect(msg).toHaveStyle({
|
||||||
|
fontSize: '20px',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -170,7 +170,7 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
|
|||||||
});
|
});
|
||||||
flush(component, mergedComponentToken);
|
flush(component, mergedComponentToken);
|
||||||
return [
|
return [
|
||||||
options.resetStyle === false ? null : genCommonStyle(token, prefixCls),
|
options.resetStyle === false ? null : genCommonStyle(mergedToken, prefixCls),
|
||||||
styleInterpolation,
|
styleInterpolation,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user