|
@ -65,7 +65,7 @@ describe('Typography.Ellipsis', () => { |
|
|
'Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light'; |
|
|
'Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light Bamboo is Little Light'; |
|
|
|
|
|
|
|
|
it('should trigger update', async () => { |
|
|
it('should trigger update', async () => { |
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const onEllipsis = jest.fn(); |
|
|
const onEllipsis = jest.fn(); |
|
|
const { container, rerender, unmount } = render( |
|
|
const { container, rerender, unmount } = render( |
|
|
<Base ellipsis={{ onEllipsis }} component="p" editable ref={ref}> |
|
|
<Base ellipsis={{ onEllipsis }} component="p" editable ref={ref}> |
|
@ -73,7 +73,7 @@ describe('Typography.Ellipsis', () => { |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
expect(container.firstChild?.textContent).toEqual('Bamboo is Little ...'); |
|
|
expect(container.firstChild?.textContent).toEqual('Bamboo is Little ...'); |
|
@ -128,7 +128,7 @@ describe('Typography.Ellipsis', () => { |
|
|
design language for background applications, is refined by Ant UED Team. |
|
|
design language for background applications, is refined by Ant UED Team. |
|
|
Ant Design, a design language for background applications, is refined by |
|
|
Ant Design, a design language for background applications, is refined by |
|
|
Ant UED Team.`;
|
|
|
Ant UED Team.`;
|
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const onEllipsis = jest.fn(); |
|
|
const onEllipsis = jest.fn(); |
|
|
const { container: wrapper, unmount } = render( |
|
|
const { container: wrapper, unmount } = render( |
|
|
<Base ellipsis={{ onEllipsis }} component="p" editable ref={ref}> |
|
|
<Base ellipsis={{ onEllipsis }} component="p" editable ref={ref}> |
|
@ -136,7 +136,7 @@ describe('Typography.Ellipsis', () => { |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
expect(wrapper.firstChild?.textContent).toEqual('Ant Design, a des...'); |
|
|
expect(wrapper.firstChild?.textContent).toEqual('Ant Design, a des...'); |
|
@ -149,14 +149,14 @@ describe('Typography.Ellipsis', () => { |
|
|
|
|
|
|
|
|
it('should middle ellipsis', async () => { |
|
|
it('should middle ellipsis', async () => { |
|
|
const suffix = '--suffix'; |
|
|
const suffix = '--suffix'; |
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const { container: wrapper, unmount } = render( |
|
|
const { container: wrapper, unmount } = render( |
|
|
<Base ellipsis={{ rows: 1, suffix }} component="p" ref={ref}> |
|
|
<Base ellipsis={{ rows: 1, suffix }} component="p" ref={ref}> |
|
|
{fullStr} |
|
|
{fullStr} |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
expect(wrapper.querySelector('p')?.textContent).toEqual('Bamboo is...--suffix'); |
|
|
expect(wrapper.querySelector('p')?.textContent).toEqual('Bamboo is...--suffix'); |
|
@ -165,7 +165,7 @@ describe('Typography.Ellipsis', () => { |
|
|
|
|
|
|
|
|
it('should front or middle ellipsis', async () => { |
|
|
it('should front or middle ellipsis', async () => { |
|
|
const suffix = '--The information is very important'; |
|
|
const suffix = '--The information is very important'; |
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const { |
|
|
const { |
|
|
container: wrapper, |
|
|
container: wrapper, |
|
|
rerender, |
|
|
rerender, |
|
@ -176,7 +176,7 @@ describe('Typography.Ellipsis', () => { |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
expect(wrapper.querySelector('p')?.textContent).toEqual( |
|
|
expect(wrapper.querySelector('p')?.textContent).toEqual( |
|
@ -206,7 +206,7 @@ describe('Typography.Ellipsis', () => { |
|
|
const bamboo = 'Bamboo'; |
|
|
const bamboo = 'Bamboo'; |
|
|
const is = ' is '; |
|
|
const is = ' is '; |
|
|
|
|
|
|
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const { container: wrapper } = render( |
|
|
const { container: wrapper } = render( |
|
|
<Base ellipsis component="p" editable ref={ref}> |
|
|
<Base ellipsis component="p" editable ref={ref}> |
|
|
{bamboo} |
|
|
{bamboo} |
|
@ -216,7 +216,7 @@ describe('Typography.Ellipsis', () => { |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
expect(wrapper.textContent).toEqual('Bamboo is Little...'); |
|
|
expect(wrapper.textContent).toEqual('Bamboo is Little...'); |
|
@ -322,13 +322,13 @@ describe('Typography.Ellipsis', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
async function getWrapper(tooltip?: EllipsisConfig['tooltip']) { |
|
|
async function getWrapper(tooltip?: EllipsisConfig['tooltip']) { |
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const wrapper = render( |
|
|
const wrapper = render( |
|
|
<Base ellipsis={{ tooltip }} component="p" ref={ref}> |
|
|
<Base ellipsis={{ tooltip }} component="p" ref={ref}> |
|
|
{fullStr} |
|
|
{fullStr} |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
return wrapper; |
|
|
return wrapper; |
|
|
} |
|
|
} |
|
@ -419,13 +419,13 @@ describe('Typography.Ellipsis', () => { |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const ref = React.createRef<any>(); |
|
|
const ref = React.createRef<HTMLElement>(); |
|
|
const { container, baseElement } = render( |
|
|
const { container, baseElement } = render( |
|
|
<Base component={undefined} ellipsis={{ tooltip: 'This is tooltip', rows: 2 }} ref={ref}> |
|
|
<Base component={undefined} ellipsis={{ tooltip: 'This is tooltip', rows: 2 }} ref={ref}> |
|
|
Ant Design, a design language for background applications, is refined by Ant UED Team. |
|
|
Ant Design, a design language for background applications, is refined by Ant UED Team. |
|
|
</Base>, |
|
|
</Base>, |
|
|
); |
|
|
); |
|
|
triggerResize(ref.current); |
|
|
triggerResize(ref.current!); |
|
|
await waitFakeTimer(); |
|
|
await waitFakeTimer(); |
|
|
|
|
|
|
|
|
fireEvent.mouseEnter(container.firstChild!); |
|
|
fireEvent.mouseEnter(container.firstChild!); |
|
|