Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated a single test to be async #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,322 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiContextMenu is rendered 1`] = `
<div
aria-label="aria-label"
class="euiContextMenu testClass1 testClass2"
data-test-subj="test subject string"
/>
`;

exports[`EuiContextMenu props panels and initialPanelId allows you to click the title button to go back to the previous panel 1`] = `
<div
class="euiContextMenu"
style="height: 0px;"
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
>
<button
class="euiContextMenuPanelTitle"
data-test-subj="contextMenuPanelTitleButton"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<svg
class="euiIcon euiIcon--medium euiContextMenu__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_left-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="rotate(90 8 8)"
xlink:href="#arrow_left-a"
/>
</svg>
<span
class="euiContextMenu__text"
>
2
</span>
</span>
</button>
<div>
<div>
2
</div>
</div>
</div>
</div>
`;

exports[`EuiContextMenu props panels and initialPanelId allows you to click the title button to go back to the previous panel 2`] = `
<div
class="euiContextMenu"
style="height: 0px;"
>
<div
class="euiContextMenuPanel euiContextMenu__panel euiContextMenuPanel-txOutRight"
tabindex="0"
>
<button
class="euiContextMenuPanelTitle"
data-test-subj="contextMenuPanelTitleButton"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<svg
class="euiIcon euiIcon--medium euiContextMenu__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_left-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="rotate(90 8 8)"
xlink:href="#arrow_left-a"
/>
</svg>
<span
class="euiContextMenu__text"
>
2
</span>
</span>
</button>
<div>
<div>
2
</div>
</div>
</div>
<div
class="euiContextMenuPanel euiContextMenu__panel euiContextMenuPanel-txInRight"
tabindex="0"
>
<button
class="euiContextMenuPanelTitle"
data-test-subj="contextMenuPanelTitleButton"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<svg
class="euiIcon euiIcon--medium euiContextMenu__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_left-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="rotate(90 8 8)"
xlink:href="#arrow_left-a"
/>
</svg>
<span
class="euiContextMenu__text"
>
1
</span>
</span>
</button>
<div>
<button
class="euiContextMenuItem"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<span
class="euiContextMenuItem__text"
>
2a
</span>
<svg
class="euiIcon euiIcon--medium euiContextMenu__arrow"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_right-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="matrix(0 1 1 0 0 0)"
xlink:href="#arrow_right-a"
/>
</svg>
</span>
</button>
<button
class="euiContextMenuItem"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<span
class="euiContextMenuItem__text"
>
2b
</span>
<svg
class="euiIcon euiIcon--medium euiContextMenu__arrow"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_right-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="matrix(0 1 1 0 0 0)"
xlink:href="#arrow_right-a"
/>
</svg>
</span>
</button>
<button
class="euiContextMenuItem"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<span
class="euiContextMenuItem__text"
>
2c
</span>
<svg
class="euiIcon euiIcon--medium euiContextMenu__arrow"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_right-a"
/>
</defs>
<use
fill-rule="nonzero"
transform="matrix(0 1 1 0 0 0)"
xlink:href="#arrow_right-a"
/>
</svg>
</span>
</button>
</div>
</div>
</div>
`;

exports[`EuiContextMenu props panels and initialPanelId renders the referenced panel 1`] = `
<div
class="euiContextMenu"
>
<div
class="euiContextMenuPanel euiContextMenu__panel"
tabindex="0"
>
<button
class="euiContextMenuPanelTitle"
data-test-subj="contextMenuPanelTitleButton"
type="button"
>
<span
class="euiContextMenu__itemLayout"
>
<svg
class="euiIcon euiIcon--medium euiContextMenu__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_left-a"
/>
</defs>
<use
fill-rule="nonzero"
href="#arrow_left-a"
transform="rotate(90 8 8)"
/>
</svg>
<span
class="euiContextMenu__text"
>
2
</span>
</span>
</button>
<div>
<div>
2
</div>
</div>
</div>
</div>
`;

exports[`EuiContextMenuPanel is rendered 1`] = `
<div
aria-label="aria-label"
Expand Down
2 changes: 1 addition & 1 deletion src/components/context_menu/context_menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const panels = [
panel2,
];

const tick = (ms = 0) => new Promise(resolve => {
export const tick = (ms = 0) => new Promise(resolve => {
setTimeout(resolve, ms);
});

Expand Down
6 changes: 5 additions & 1 deletion src/components/context_menu/context_menu_panel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
EuiContextMenuItem,
} from './context_menu_item';

import { tick } from './context_menu.test';

import { keyCodes } from '../../services';

const items = [
Expand Down Expand Up @@ -162,14 +164,16 @@ describe('EuiContextMenuPanel', () => {
});

describe('initialFocusedItemIndex', () => {
it('sets focus on the item occupying that index', () => {
it('sets focus on the item occupying that index', async () => {
const component = mount(
<EuiContextMenuPanel
items={items}
initialFocusedItemIndex={1}
/>
);

await tick(20);

expect(findTestSubject(component, 'itemB').getDOMNode()).toBe(document.activeElement);
});
});
Expand Down