Skip to content

Commit

Permalink
fix: autoFocus keeps in props. move test case
Browse files Browse the repository at this point in the history
  • Loading branch information
baxtergu committed Apr 1, 2021
1 parent 5924b87 commit 9c42d35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/DrawerWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
wrapperClassName,
forceRender,
handler,
autoFocus,
...props
} = this.props;
const { open } = this.state;
Expand Down
24 changes: 0 additions & 24 deletions tests/drawer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,6 @@ const DrawerTesterBoolean = props => (
</div>
);

/* eslint react/no-multi-comp: 0 */
// tslint:disable-next-line:max-classes-per-file
const DrawerTesterAutoFocus = props => (
<div>
<Drawer
{...props}
autoFocus={false}
open={true}
getContainer={false}
wrapperClassName="autofocus-test-wrapper-class-name"
>
<p className="text">Here is content of Drawer</p>
</Drawer>
</div>
);

describe('Drawer', () => {
it('render function', () => {
const wrapper = mount(<DrawerTesterRef />);
Expand All @@ -105,12 +89,4 @@ describe('Drawer', () => {
const wrapper = mount(<DrawerTesterBoolean />);
expect(toJson(wrapper.render())).toMatchSnapshot();
});

it('render autoFocus', () => {
const wrapper = mount(<DrawerTesterAutoFocus />);
expect(
wrapper.find('.autofocus-test-wrapper-class-name').is(':focus'),
).toBe(false);
expect(toJson(wrapper.render())).toMatchSnapshot();
});
});
19 changes: 19 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,23 @@ describe('rc-drawer-menu', () => {
const content = instance.find('.drawer-content-wrapper').instance() as any;
expect(content.style.background).toBe('rgb(255, 0, 0)');
});

it('autoFocus:false', () => {
instance = mount(
<div>
<Drawer
autoFocus={false}
open={true}
getContainer={false}
wrapperClassName="autofocus-test-wrapper-class-name"
>
<p className="text">Here is content of Drawer</p>
</Drawer>
</div>,
);

expect(
instance.find('.autofocus-test-wrapper-class-name').is(':focus'),
).toBe(false);
});
});

0 comments on commit 9c42d35

Please sign in to comment.