mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
Add missing KuiPopover tests. (#14433)
This commit is contained in:
parent
13fbbcf410
commit
c107b0aea0
2 changed files with 182 additions and 79 deletions
|
@ -1,29 +1,5 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`KuiPopover anchorPosition defaults to center 1`] = `
|
|
||||||
<div
|
|
||||||
class="kuiPopover"
|
|
||||||
>
|
|
||||||
<button />
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`KuiPopover anchorPosition left is rendered 1`] = `
|
|
||||||
<div
|
|
||||||
class="kuiPopover kuiPopover--anchorLeft"
|
|
||||||
>
|
|
||||||
<button />
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`KuiPopover anchorPosition right is rendered 1`] = `
|
|
||||||
<div
|
|
||||||
class="kuiPopover kuiPopover--anchorRight"
|
|
||||||
>
|
|
||||||
<button />
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`KuiPopover children is rendered 1`] = `
|
exports[`KuiPopover children is rendered 1`] = `
|
||||||
<div
|
<div
|
||||||
class="kuiPopover"
|
class="kuiPopover"
|
||||||
|
@ -42,7 +18,7 @@ exports[`KuiPopover is rendered 1`] = `
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`KuiPopover isOpen defaults to false 1`] = `
|
exports[`KuiPopover props anchorPosition defaults to center 1`] = `
|
||||||
<div
|
<div
|
||||||
class="kuiPopover"
|
class="kuiPopover"
|
||||||
>
|
>
|
||||||
|
@ -50,7 +26,31 @@ exports[`KuiPopover isOpen defaults to false 1`] = `
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`KuiPopover isOpen renders true 1`] = `
|
exports[`KuiPopover props anchorPosition left is rendered 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover kuiPopover--anchorLeft"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props anchorPosition right is rendered 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover kuiPopover--anchorRight"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props isOpen defaults to false 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props isOpen renders true 1`] = `
|
||||||
<div
|
<div
|
||||||
class="kuiPopover"
|
class="kuiPopover"
|
||||||
>
|
>
|
||||||
|
@ -62,3 +62,37 @@ exports[`KuiPopover isOpen renders true 1`] = `
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props panelClassName is rendered 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="kuiPanelSimple kuiPanelSimple--paddingMedium kuiPanelSimple--shadow kuiPopover__panel test"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props panelPaddingSize is rendered 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="kuiPanelSimple kuiPanelSimple--paddingSmall kuiPanelSimple--shadow kuiPopover__panel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`KuiPopover props withTitle is rendered 1`] = `
|
||||||
|
<div
|
||||||
|
class="kuiPopover kuiPopover--withTitle"
|
||||||
|
>
|
||||||
|
<button />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from 'enzyme';
|
import { render, mount } from 'enzyme';
|
||||||
|
import sinon from 'sinon';
|
||||||
import { requiredProps } from '../../test/required_props';
|
import { requiredProps } from '../../test/required_props';
|
||||||
|
|
||||||
import { KuiPopover } from './popover';
|
import { KuiPopover } from './popover';
|
||||||
|
|
||||||
|
import { keyCodes } from '../../services';
|
||||||
|
|
||||||
describe('KuiPopover', () => {
|
describe('KuiPopover', () => {
|
||||||
test('is rendered', () => {
|
test('is rendered', () => {
|
||||||
const component = render(
|
const component = render(
|
||||||
|
@ -32,6 +35,39 @@ describe('KuiPopover', () => {
|
||||||
.toMatchSnapshot();
|
.toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('props', () => {
|
||||||
|
describe('withTitle', () => {
|
||||||
|
test('is rendered', () => {
|
||||||
|
const component = render(
|
||||||
|
<KuiPopover
|
||||||
|
withTitle
|
||||||
|
button={<button />}
|
||||||
|
closePopover={() => {}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(component)
|
||||||
|
.toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('closePopover', () => {
|
||||||
|
it('is called when ESC key is hit', () => {
|
||||||
|
const closePopoverHandler = sinon.stub();
|
||||||
|
|
||||||
|
const component = mount(
|
||||||
|
<KuiPopover
|
||||||
|
withTitle
|
||||||
|
button={<button />}
|
||||||
|
closePopover={closePopoverHandler}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
component.simulate('keydown', { keyCode: keyCodes.ESCAPE });
|
||||||
|
sinon.assert.calledOnce(closePopoverHandler);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('anchorPosition', () => {
|
describe('anchorPosition', () => {
|
||||||
test('defaults to center', () => {
|
test('defaults to center', () => {
|
||||||
const component = render(
|
const component = render(
|
||||||
|
@ -90,7 +126,39 @@ describe('KuiPopover', () => {
|
||||||
<KuiPopover
|
<KuiPopover
|
||||||
button={<button />}
|
button={<button />}
|
||||||
closePopover={() => {}}
|
closePopover={() => {}}
|
||||||
isOpen={true}
|
isOpen
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(component)
|
||||||
|
.toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('panelClassName', () => {
|
||||||
|
test('is rendered', () => {
|
||||||
|
const component = render(
|
||||||
|
<KuiPopover
|
||||||
|
button={<button />}
|
||||||
|
closePopover={() => {}}
|
||||||
|
panelClassName="test"
|
||||||
|
isOpen
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(component)
|
||||||
|
.toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('panelPaddingSize', () => {
|
||||||
|
test('is rendered', () => {
|
||||||
|
const component = render(
|
||||||
|
<KuiPopover
|
||||||
|
button={<button />}
|
||||||
|
closePopover={() => {}}
|
||||||
|
panelPaddingSize="s"
|
||||||
|
isOpen
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -99,3 +167,4 @@ describe('KuiPopover', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue