Skip to content

Commit

Permalink
Updated tests to use react testing library
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Dec 1, 2021
1 parent a071dcb commit d809038
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 60 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/dropdown/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
*/
import Dropdown from '../';
import Button from '../../button';
import { MenuGroup } from '../../menu-group';
import MenuGroup from '../../menu-group';
import MenuItem from '../../menu-item';
import DropdownMenu from '../../dropdown-menu';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export {
} from './item-group';
export { default as __experimentalInputControl } from './input-control';
export { default as KeyboardShortcuts } from './keyboard-shortcuts';
export { MenuGroup } from './menu-group';
export { default as MenuGroup } from './menu-group';
export { default as MenuItem } from './menu-item';
export { default as MenuItemsChoice } from './menu-items-choice';
export { default as Modal } from './modal';
Expand Down
44 changes: 0 additions & 44 deletions packages/components/src/menu-group/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/components/src/menu-group/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/src/menu-group/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { boolean, text } from '@storybook/addon-knobs';
/**
* Internal dependencies
*/
import { MenuGroup } from '../';
import MenuGroup from '../';

export default {
title: 'Components/MenuGroup',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MenuGroup should match snapshot 1`] = `
exports[`MenuGroup should render correctly 1`] = `
.emotion-0+.components-menu-group {
margin-top: calc(4px * 2);
padding-top: calc(4px * 2);
border-top: 1px solid #1e1e1e;
}
.emotion-2 {
padding: 0 calc(4px * 2);
margin-top: calc(4px * 1);
margin-bottom: calc(4px * 3);
color: #757575;
text-transform: uppercase;
font-size: calc(0.92 * 13px);
font-weight: 600;
white-space: nowrap;
}
<div
className="components-menu-group"
class="components-menu-group emotion-0 emotion-1"
>
<div
aria-hidden="true"
className="components-menu-group__label"
class="components-menu-group__label emotion-2 emotion-1"
id="components-menu-group-label-1"
>
My group
</div>
<div
aria-labelledby="components-menu-group-label-1"
class="emotion-4 emotion-1"
role="group"
>
<p>
Expand Down
15 changes: 7 additions & 8 deletions packages/components/src/menu-group/test/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
/**
* External dependencies
*/
import { shallow } from 'enzyme';
import { render } from '@testing-library/react';

/**
* Internal dependencies
*/
import { MenuGroup } from '../';
import MenuGroup from '../';

describe( 'MenuGroup', () => {
test( 'should render null when no children provided', () => {
const wrapper = shallow( <MenuGroup /> );
const wrapper = render( <MenuGroup /> );

expect( wrapper.html() ).toBe( null );
expect( wrapper.container.firstChild ).toBe( null );
} );

test( 'should match snapshot', () => {
const wrapper = shallow(
test( 'should render correctly', () => {
const wrapper = render(
<MenuGroup label="My group" instanceId="1">
<p>My item</p>
</MenuGroup>
);

expect( wrapper ).toMatchSnapshot();
expect( wrapper.container.firstChild ).toMatchSnapshot();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __, _x, sprintf } from '@wordpress/i18n';
* Internal dependencies
*/
import DropdownMenu from '../../dropdown-menu';
import { MenuGroup } from '../../menu-group';
import MenuGroup from '../../menu-group';
import MenuItem from '../../menu-item';
import { HStack } from '../../h-stack';
import { Heading } from '../../heading';
Expand Down

0 comments on commit d809038

Please sign in to comment.