ant-design-vue/components/form/__tests__/index.test.js

39 lines
840 B
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import Form from '..';
2018-06-28 13:41:02 +00:00
describe('Form', () => {
it('hideRequiredMark', () => {
const wrapper = mount(Form, {
propsData: {
hideRequiredMark: true,
},
2019-01-12 03:33:27 +00:00
});
expect(wrapper.classes()).toContain('ant-form-hide-required-mark');
});
2018-06-28 13:41:02 +00:00
describe('wrappedComponentRef', () => {
it('get component ref', () => {
const TestForm = {
2019-01-12 03:33:27 +00:00
data() {
2018-06-28 13:41:02 +00:00
return {
__TESTFORM__: true,
2019-01-12 03:33:27 +00:00
};
2018-06-28 13:41:02 +00:00
},
2019-01-12 03:33:27 +00:00
render() {
return <Form />;
2018-06-28 13:41:02 +00:00
},
2019-01-12 03:33:27 +00:00
};
const Wrapped = Form.create()(TestForm);
let form;
2018-06-28 13:41:02 +00:00
mount(Wrapped, {
propsData: {
2019-01-12 03:33:27 +00:00
wrappedComponentRef: node => {
form = node;
},
2018-06-28 13:41:02 +00:00
},
2019-01-12 03:33:27 +00:00
});
expect(form._data.__TESTFORM__).toBe(true);
});
});
});