UNPKG

devextreme-vue

Version:

DevExtreme Vue UI and Visualization Components

106 lines (104 loc) 3.6 kB
/*! * devextreme-vue * Version: 25.1.6 * Build date: Mon Oct 13 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 */ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const test_utils_1 = require("@vue/test-utils"); const vue_1 = require("vue"); const vue_router_1 = require("vue-router"); const button_1 = __importDefault(require("../../button")); jest.setTimeout(1000); beforeEach(() => { jest.clearAllMocks(); }); describe('template rendering', () => { it('should render a template with child router-view', async () => { const appView = (0, vue_1.defineComponent)({ template: `<dx-button id="component"> <template #content> <router-view name="test"></router-view> </template> </dx-button>`, components: { DxButton: button_1.default, }, }); const rootView = (0, vue_1.defineComponent)({ template: ` <router-view></router-view> `, }); const testView = (0, vue_1.defineComponent)({ template: ` <div class="test">text</div> `, }); const router = (0, vue_router_1.createRouter)({ routes: [ { name: 'rootview', path: '/', component: appView, redirect: '/test', children: [ { name: 'testview', path: '/test', components: { test: testView }, }, ], }, { path: '/:pathMatch(.*)*', redirect: '/', }, ], history: (0, vue_router_1.createWebHistory)(), }); await router.push('/'); await router.isReady(); const wrapper = (0, test_utils_1.mount)(rootView, { global: { plugins: [router], }, }); expect(wrapper.vm.$el.getElementsByClassName('test')).toHaveLength(1); }); it('should unmount template with two childs in root without exception', async () => { const appView = (0, vue_1.defineComponent)({ props: { templateName: { type: String, value: 'tpl1', }, }, template: `<dx-button id="component" :template="templateName"> <template #tpl1> <div>1</div> <div>2</div> </template> <template #tpl2> <div>3</div> <div>4</div> </template> </dx-button>`, components: { DxButton: button_1.default, }, }); const wrapper = (0, test_utils_1.mount)(appView, { props: { templateName: 'tpl1' } }); expect(() => wrapper.setProps({ templateName: 'tpl2' })).not.toThrow(); }); });