Skip to content

Commit

Permalink
test: add easySelect test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeZhang committed Aug 12, 2020
1 parent 50a1fd7 commit 4201cf4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/easy-select/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import React from 'react';
import EasySelect from '../index';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

let wrapper: any, element: any

describe('test EasySelect', () => {
beforeEach(() => {
wrapper = render(
<EasySelect
data-testid='test-easySelect'
dataSource={[{ value: 1, label: '张三' }, { value: 2, label: '李四' }]}
/>
)
element = wrapper.getByTestId('test-easySelect');
})
afterEach(() => {
cleanup();
})
test('should render correct', () => {
expect(element).toBeInTheDocument();
expect(element.classList.contains('ant-select-selection')).toEqual(true);
expect(element.childNodes.length).toBe(2);
})
})
1 change: 1 addition & 0 deletions src/components/easy-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class EasySelect extends React.Component<any, any> {
const { dataSource } = this.state;
return (
<Select
data-testid='test-easySelect'
allowClear={allowClear} // 默认支持清除
showSearch={showSearch} // 默认支持查询
style={{ minWidth: 120 }} // todo: 暂时样式,有待商榷
Expand Down

0 comments on commit 4201cf4

Please sign in to comment.