2015-11-04 17:15:33 +08:00
|
|
|
import React from 'react';
|
2016-06-22 22:31:00 +08:00
|
|
|
import TestUtils from 'react-addons-test-utils';
|
2016-11-22 13:43:53 +08:00
|
|
|
import Popover from '../../components/popover/index';
|
2015-11-04 17:15:33 +08:00
|
|
|
|
2016-06-22 22:31:00 +08:00
|
|
|
describe('Popover', function() {
|
|
|
|
it('should show overlay when trigger is clicked', () => {
|
|
|
|
const popover = TestUtils.renderIntoDocument(
|
|
|
|
<Popover content="console.log('hello world')" title="code" trigger="click">
|
|
|
|
<a href="#">show me your code</a>
|
|
|
|
</Popover>
|
|
|
|
);
|
2015-11-04 17:15:33 +08:00
|
|
|
|
2016-07-07 23:01:43 +08:00
|
|
|
expect(popover.getPopupDomNode()).toBe(null);
|
2015-11-04 17:15:33 +08:00
|
|
|
|
2016-06-22 22:31:00 +08:00
|
|
|
TestUtils.Simulate.click(
|
|
|
|
TestUtils.findRenderedDOMComponentWithTag(popover, 'a')
|
|
|
|
);
|
2015-11-04 17:15:33 +08:00
|
|
|
|
2016-06-22 22:31:00 +08:00
|
|
|
const popup = popover.getPopupDomNode();
|
2016-07-09 18:30:09 +08:00
|
|
|
expect(popup).not.toBe(null);
|
2016-06-22 22:31:00 +08:00
|
|
|
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>/);
|
|
|
|
});
|
2015-11-04 17:15:33 +08:00
|
|
|
});
|