2016-12-14 14:48:09 +08:00
|
|
|
import React from 'react';
|
2017-04-12 20:49:02 +08:00
|
|
|
import TestUtils from 'react-dom/test-utils';
|
2016-12-14 14:48:09 +08:00
|
|
|
import Popover from '..';
|
|
|
|
|
|
|
|
describe('Popover', () => {
|
|
|
|
it('should show overlay when trigger is clicked', () => {
|
|
|
|
const popover = TestUtils.renderIntoDocument(
|
|
|
|
<Popover content="console.log('hello world')" title="code" trigger="click">
|
|
|
|
<span>show me your code</span>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(popover.getPopupDomNode()).toBe(null);
|
|
|
|
|
|
|
|
TestUtils.Simulate.click(
|
|
|
|
TestUtils.findRenderedDOMComponentWithTag(popover, 'span')
|
|
|
|
);
|
|
|
|
|
|
|
|
const popup = popover.getPopupDomNode();
|
|
|
|
expect(popup).not.toBe(null);
|
|
|
|
expect(popup.className).toContain('ant-popover-placement-top');
|
|
|
|
expect(popup.innerHTML).toMatch(/<div class="ant-popover-title".*?>code<\/div>/);
|
|
|
|
expect(popup.innerHTML).toMatch(/<div class="ant-popover-inner-content".*?>console\.log\('hello world'\)<\/div>/);
|
|
|
|
});
|
|
|
|
});
|