mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-26 20:20:00 +08:00
8501b708ea
* 📦 samller bundlesize limit * 🗑️ remove React static PropTypes * 🗑️ remove react-lifecycles-compat * 🗑️ remove matchMedia polyfill * 🗑️ remove Transfer buggy lazy prop * 🗑️ remove enquire.js dep * 🗑️ remove Transfer lazy related code and fix ci * 🗑️ remove used dom-closest * ⚡ replace dom-scroll-into-view to scroll-into-view for bundle size * ✅ fix eslint * 🆙 upgrade browserslist * ✅ fix test cases * 🗑️ remove @ant-design/create-react-context * 🆙 upgrade @ant-design/bisheng-plugin * 🆙 upgrade rc-slider * ✅ fix ci * 🆙 upgrade rc-tabs and rc-mentions * 📦 scroll-into-view -> scroll-into-view-if-needed * remove unused devDep * docs: 📝 update instruction about IE9/10 * 📦 reduce css bundle size by drop IE9/10 support * 🆙 upgrade rc-upload * 🗑️ drop unused swing motion css * ✅ update upload snapshots * 📦 lift css bundlesize limit to 55kb
58 lines
1.5 KiB
JavaScript
58 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.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.instance().handleFilter({ target: 'test' })).toBe(undefined);
|
|
expect(handleFilter).toHaveBeenCalled();
|
|
});
|
|
});
|