fix: component token should work (#45721)

This commit is contained in:
MadCcc 2023-11-08 16:27:50 +08:00 committed by GitHub
parent b99902ab76
commit c3a63a9927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* 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 { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs';
import message from '..';
@ -271,4 +271,32 @@ describe('message.hooks', () => {
const styleText = extractStyle(cache, true);
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',
});
});
});

View File

@ -170,7 +170,7 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
});
flush(component, mergedComponentToken);
return [
options.resetStyle === false ? null : genCommonStyle(token, prefixCls),
options.resetStyle === false ? null : genCommonStyle(mergedToken, prefixCls),
styleInterpolation,
];
},