2019-05-07 17:10:42 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Transfer from '../index';
|
|
|
|
|
|
|
|
describe('Transfer.Customize', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
errorSpy.mockReset();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
2019-07-09 11:46:21 +08:00
|
|
|
it('props#body doesnot work anymore', () => {
|
|
|
|
const body = jest.fn();
|
|
|
|
mount(<Transfer body={body} />);
|
2019-05-07 17:10:42 +08:00
|
|
|
|
2019-07-09 11:46:21 +08:00
|
|
|
expect(errorSpy.mock.calls.length).toBe(0);
|
|
|
|
expect(body).not.toHaveBeenCalled();
|
2019-05-07 17:10:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('deprecated function', () => {
|
|
|
|
const dataSource = [];
|
|
|
|
for (let i = 0; i < 10; i += 1) {
|
|
|
|
dataSource.push({
|
|
|
|
key: i.toString(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const commonProps = {
|
|
|
|
dataSource,
|
|
|
|
selectedKeys: ['1'],
|
|
|
|
targetKeys: ['2'],
|
|
|
|
};
|
|
|
|
|
|
|
|
it('should not exist in render props', () => {
|
|
|
|
mount(
|
|
|
|
<Transfer {...commonProps}>
|
|
|
|
{props => {
|
|
|
|
expect('handleFilter' in props).toBeFalsy();
|
|
|
|
expect('handleSelect' in props).toBeFalsy();
|
|
|
|
expect('handleSelectAll' in props).toBeFalsy();
|
|
|
|
expect('handleClear' in props).toBeFalsy();
|
|
|
|
expect('body' in props).toBeFalsy();
|
|
|
|
expect('checkedKeys' in props).toBeFalsy();
|
|
|
|
}}
|
|
|
|
</Transfer>,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|