Skip to content

Commit

Permalink
updated a single test to be async
Browse files Browse the repository at this point in the history
  • Loading branch information
chandlerprall committed Jul 16, 2018
1 parent ac9265d commit 4f5d128
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 2 deletions.
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

0 comments on commit 4f5d128

Please sign in to comment.