ant-design-vue/components/transfer/__tests__/list.test.js

52 lines
981 B
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
import { mount } from '@vue/test-utils';
import List from '../list';
2018-05-23 16:07:02 +08:00
const listCommonProps = {
prefixCls: 'ant-transfer-list',
2019-01-12 11:33:27 +08:00
dataSource: [
{
key: 'a',
title: 'a',
},
{
key: 'b',
title: 'b',
},
{
key: 'c',
title: 'c',
disabled: true,
},
],
2018-05-23 16:07:02 +08:00
checkedKeys: ['a'],
notFoundContent: 'Not Found',
lazy: false,
2019-01-12 11:33:27 +08:00
};
2018-05-23 16:07:02 +08:00
describe('List', () => {
it('should render correctly', () => {
const props = {
2020-07-25 15:46:49 +08:00
props: listCommonProps,
2019-01-12 11:33:27 +08:00
};
2020-08-14 17:04:45 +08:00
const wrapper = mount(List, props);
expect(wrapper.html()).toMatchSnapshot();
2019-01-12 11:33:27 +08:00
});
2018-05-23 16:07:02 +08:00
it('should check top Checkbox while all available items are checked', () => {
const props = {
2020-07-25 15:46:49 +08:00
props: {
2018-05-23 16:07:02 +08:00
...listCommonProps,
checkedKeys: ['a', 'b'],
},
2019-01-12 11:33:27 +08:00
};
const wrapper = mount(List, props);
expect(
wrapper
2020-08-14 17:04:45 +08:00
.findComponent({
2019-01-12 11:33:27 +08:00
name: 'ACheckbox',
})
.props().checked,
).toBeTruthy();
});
});