Skip to content

Commit

Permalink
refactor(drawer): rewrite with hook from @hosseinmd (ant-design#29229)
Browse files Browse the repository at this point in the history
* refactor: drawer to functional component and  hooks

* chore: clean code default value

* perf: remove doesn't necessary useCallback

* chore: useContext instead of Consumer

* fix ref

* Add Drawer displayName

* fix tsc

* fix tsc

Co-authored-by: Hossein Mohammadi <[email protected]>
  • Loading branch information
afc163 and hosseinmd authored Feb 5, 2021
1 parent d7d2cef commit 4ee9253
Show file tree
Hide file tree
Showing 3 changed files with 273 additions and 235 deletions.
11 changes: 11 additions & 0 deletions components/drawer/__tests__/Drawer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,15 @@ describe('Drawer', () => {

errorSpy.mockRestore();
});

it('should support ref', () => {
const ref = React.createRef();
mount(
<Drawer visible ref={ref} width={400}>
Here is content of Drawer
</Drawer>,
);
expect(typeof ref.current.push).toBe('function');
expect(typeof ref.current.pull).toBe('function');
});
});
23 changes: 23 additions & 0 deletions components/drawer/__tests__/type.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import Drawer from '..';

describe('Drawer.typescript', () => {
it('Drawer', () => {
const onClose = jest.fn();
const wrapper = (
<Drawer
title="Basic Drawer"
placement="right"
closable={false}
onClose={onClose}
visible={false}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
);

expect(wrapper).toBeTruthy();
});
});
Loading

0 comments on commit 4ee9253

Please sign in to comment.