mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-11 10:05:07 +08:00
30ac6bd4e4
* test: React StrictMode * test: fix Spin test * chore: wrapper enzyme * test: fix setState * test: more test cover * test: more test cover * test: more test cover * test: more test cover * test: more test cover * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: disable part of it * test: fix test & add placeholder * test: Use orign enzyme mount Co-authored-by: zombiej <smith3816@gmail.com>
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import List from '../list';
|
|
import Checkbox from '../../checkbox';
|
|
|
|
const listCommonProps = {
|
|
prefixCls: 'ant-transfer-list',
|
|
dataSource: [
|
|
{
|
|
key: 'a',
|
|
title: 'a',
|
|
},
|
|
{
|
|
key: 'b',
|
|
title: 'b',
|
|
},
|
|
{
|
|
key: 'c',
|
|
title: 'c',
|
|
disabled: true,
|
|
},
|
|
],
|
|
checkedKeys: ['a'],
|
|
notFoundContent: 'Not Found',
|
|
};
|
|
|
|
describe('Transfer.List', () => {
|
|
it('should render correctly', () => {
|
|
const wrapper = mount(<List {...listCommonProps} />);
|
|
wrapper.update();
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should check top Checkbox while all available items are checked', () => {
|
|
const wrapper = mount(<List {...listCommonProps} checkedKeys={['a', 'b']} />);
|
|
expect(wrapper.find('.ant-transfer-list-header').find(Checkbox).prop('checked')).toBeTruthy();
|
|
});
|
|
|
|
it('when component has been unmounted, componentWillUnmount should be called', () => {
|
|
const wrapper = mount(<List {...listCommonProps} />);
|
|
const willUnmount = jest.spyOn(wrapper.find(List).instance(), 'componentWillUnmount');
|
|
wrapper.unmount();
|
|
expect(willUnmount).toHaveBeenCalled();
|
|
});
|
|
|
|
it('when value is not exists, handleFilter should return', () => {
|
|
const handleFilter = jest.fn();
|
|
const wrapper = mount(<List {...listCommonProps} handleFilter={handleFilter} />);
|
|
expect(wrapper.find(List).instance().handleFilter({ target: 'test' })).toBe(undefined);
|
|
expect(handleFilter).toHaveBeenCalled();
|
|
});
|
|
});
|