devextreme-vue
Version:
DevExtreme Vue UI and Visualization Components
65 lines (63 loc) • 1.89 kB
JavaScript
/*!
* devextreme-vue
* Version: 25.1.5
* Build date: Wed Sep 03 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-vue
*/
import { mount } from '@vue/test-utils';
import { defineComponent, nextTick } from 'vue';
import { DxForm, DxItem } from '../../form';
jest.setTimeout(1000);
beforeEach(() => {
jest.clearAllMocks();
});
describe('form', () => {
it('should render config components by condition', async () => {
expect.assertions(1);
const vm = defineComponent({
template: `<DxForm
id="form"
:form-data="data"
>
<DxItem
v-if="show"
data-field="FirstName"
/>
<DxItem
data-field="Position"
/>
</DxForm>`,
components: {
DxItem, DxForm,
},
props: {
show: {
type: Boolean,
default: true,
},
data: {
type: Object,
default: {
FirstName: 'name1',
Position: 'name2',
},
},
},
});
const wrapper = mount(vm);
await wrapper.setProps({ show: false });
await nextTick(() => {
wrapper.setProps({ show: true });
});
await nextTick(() => {
expect(wrapper.getComponent('#form').vm.$el
.getElementsByClassName('dx-field-item-label-text')).toHaveLength(2);
});
});
});