Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
feat: Add test and storybook for SubMenu. (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijianxin1202 authored and wangkailang committed Aug 27, 2019
1 parent 8849a31 commit 49980bf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/components/SubMenu/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import SubMenu from './index';
import { mount } from 'enzyme';

describe('SubMenu', () => {
it('render simple SubMenu', () => {
const subMenu = mount(<SubMenu title="title" children="text" />);
expect(subMenu.find('ul.dropdown-menu').length).toBe(1);
});
});
2 changes: 1 addition & 1 deletion src/components/SubMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MenuItem } from 'react-bootstrap';
import { SubMenuProps } from '../../interface';
import './style.scss';

const SubMenu: React.FC<SubMenuProps> = props => {
const SubMenu = (props: SubMenuProps) => {
const { title, children, name } = props;
return (
<div className="SubMenu" data-name={`SubMenu-${name}`}>
Expand Down
17 changes: 17 additions & 0 deletions stories/SubMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { SubMenu } from '../src';

const menuStyle = {
width: '100px',
};
const title = '第一层';
const children = <div style={{ padding: '4px' }}>下一层</div>;
storiesOf('SubMenu', module)
.add('default', () => (
<div>
<div style={menuStyle}>
<SubMenu title={title}>{children}</SubMenu>
</div>
</div>
));

0 comments on commit 49980bf

Please sign in to comment.