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

54 lines
1.1 KiB
JavaScript
Raw Normal View History

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