Browse Source

Add test case for arrowPointAtCenter, #6830

pull/6802/head
afc163 7 years ago
parent
commit
8a63b39e63
  1. 40
      components/tooltip/__tests__/tooltip.test.js

40
components/tooltip/__tests__/tooltip.test.js

@ -128,4 +128,44 @@ describe('Tooltip', () => {
expect(wrapper.find('span')).toHaveLength(0);
});
it('should works for arrowPointAtCenter', () => {
const arrowWidth = 5;
const horizontalArrowShift = 16;
const triggerWidth = 200;
const wrapper = mount(
<Tooltip
title="xxxxx"
trigger="click"
mouseEnterDelay={0}
mouseLeaveDelay={0}
placement="bottomLeft"
>
<button style={{ width: triggerWidth }}>
Hello world!
</button>
</Tooltip>
);
wrapper.find('button').at(0).simulate('click');
const popupLeftDefault = parseInt(wrapper.node.getPopupDomNode().style.left, 10);
const wrapper2 = mount(
<Tooltip
title="xxxxx"
trigger="click"
mouseEnterDelay={0}
mouseLeaveDelay={0}
placement="bottomLeft"
arrowPointAtCenter
>
<button style={{ width: triggerWidth }}>
Hello world!
</button>
</Tooltip>
);
wrapper2.find('button').at(0).simulate('click');
const popupLeftArrowPointAtCenter = parseInt(wrapper2.node.getPopupDomNode().style.left, 10);
expect(popupLeftArrowPointAtCenter - popupLeftDefault).toBe((triggerWidth / 2) - horizontalArrowShift - arrowWidth);
});
});

Loading…
Cancel
Save