2016-04-27 20:44:36 +08:00
|
|
|
jest.unmock('../components/popover/placements');
|
|
|
|
jest.unmock('../components/popover/index');
|
|
|
|
jest.unmock('../components/tooltip/index');
|
|
|
|
|
2015-11-04 17:15:33 +08:00
|
|
|
import React from 'react';
|
|
|
|
import TestUtils from 'react-addons-test-utils';
|
2016-04-27 20:44:36 +08:00
|
|
|
import Popover from '../components/popover/index';
|
2015-11-04 17:15:33 +08:00
|
|
|
|
|
|
|
describe('Popover', function() {
|
2015-12-03 15:23:54 +08:00
|
|
|
it('should show overlay when trigger is clicked', () => {
|
2015-11-04 17:15:33 +08:00
|
|
|
const popover = TestUtils.renderIntoDocument(
|
2016-04-07 16:56:13 +08:00
|
|
|
<Popover content="console.log('hello world')" title="code" trigger="click">
|
2015-11-04 17:15:33 +08:00
|
|
|
<a href="#">show me your code</a>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
|
2015-12-07 15:43:49 +08:00
|
|
|
expect(popover.getPopupDomNode()).toBe(undefined);
|
2015-11-04 17:15:33 +08:00
|
|
|
|
|
|
|
TestUtils.Simulate.click(
|
|
|
|
TestUtils.findRenderedDOMComponentWithTag(popover, 'a')
|
|
|
|
);
|
|
|
|
|
|
|
|
const popup = popover.getPopupDomNode();
|
2015-12-07 15:43:49 +08:00
|
|
|
expect(popup).not.toBe(undefined);
|
|
|
|
expect(popup.className).toContain('ant-popover-placement-top');
|
|
|
|
expect(popup.innerHTML).toMatch(/<div class="ant-popover-title".*?>code<\/div>/);
|
2016-03-20 20:37:36 +08:00
|
|
|
expect(popup.innerHTML).toMatch(/<div class="ant-popover-inner-content".*?>console\.log\('hello world'\)<\/div>/);
|
2015-11-04 17:15:33 +08:00
|
|
|
});
|
|
|
|
});
|