ant-design/tests/popover.test.js

29 lines
990 B
JavaScript
Raw Normal View History

2015-11-04 17:15:33 +08:00
import React from 'react';
import TestUtils from 'react-addons-test-utils';
jest.dontMock('../components/popover/index');
const Popover = require('../components/popover/index');
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(
<Popover overlay="console.log('hello world')" title="code" trigger="click">
<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>/);
expect(popup.innerHTML).toMatch(/<div class="ant-popover-content".*?>console\.log\('hello world'\)<\/div>/);
2015-11-04 17:15:33 +08:00
});
});