diff --git a/components/typography/Base/index.tsx b/components/typography/Base/index.tsx index 056411ba71..44c53b548c 100644 --- a/components/typography/Base/index.tsx +++ b/components/typography/Base/index.tsx @@ -462,7 +462,7 @@ const Base = React.forwardRef((props, ref) => { width={ellipsisWidth} onEllipsis={onJsEllipsis} expanded={expanded} - miscDeps={[copied, expanded, copyLoading, enableEdit, enableCopy]} + miscDeps={[copied, expanded, copyLoading, enableEdit, enableCopy, textLocale]} > {(node, canEllipsis) => wrapperDecorations( diff --git a/components/typography/__tests__/ellipsis.test.tsx b/components/typography/__tests__/ellipsis.test.tsx index 6e92e29a20..812ef49940 100644 --- a/components/typography/__tests__/ellipsis.test.tsx +++ b/components/typography/__tests__/ellipsis.test.tsx @@ -11,7 +11,10 @@ import { } from '../../../tests/utils'; import type { EllipsisConfig } from '../Base'; import Base from '../Base'; - +import ConfigProvider from '../../config-provider'; +import type { ConfigProviderProps } from '../../config-provider'; +import zhCN from '../../locale/zh_CN'; +type Locale = ConfigProviderProps['locale']; jest.mock('copy-to-clipboard'); jest.mock('../../_util/styleChecker', () => ({ @@ -644,4 +647,49 @@ describe('Typography.Ellipsis', () => { , ); }); + + it('Switch locale', async () => { + const ref = React.createRef(); + const App = () => { + const [locale, setLocal] = React.useState(); + + return ( + +
+ + + {'Ant Design, a design language for background applications, is refined by Ant UED Team.'.repeat( + 20, + )} + +
+
+ ); + }; + const { container } = render(); + + triggerResize(ref.current!); + await waitFakeTimer(); + const expandButton = container.querySelector('.ant-typography-expand'); + expect(expandButton).toHaveTextContent('Expand'); + const button = container.querySelector('button')!; + + fireEvent.click(button); + + triggerResize(ref.current!); + await waitFakeTimer(); + + const expandButtonCN = container.querySelector('.ant-typography-expand'); + expect(expandButtonCN).toHaveTextContent('展开'); + expect(expandButtonCN).toBeInTheDocument(); + }); });