mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-29 16:13:41 +08:00
Group table demos and share their dataset across the development Mock API and static previews. Restore focus after maximizing content and add column preferences, printing, and CSV export to TablePro. BREAKING CHANGE: RTable and the legacy registration hooks are removed. Use RTablePro props, slots, or the exposed instance instead.
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { shallowMount } from '@vue/test-utils'
|
|
import { createPinia, disposePinia, setActivePinia } from 'pinia'
|
|
import { h, nextTick } from 'vue'
|
|
import Layout from '../../src/layout'
|
|
import { router } from '../../src/router'
|
|
import { piniaRuntimeStore } from '../../src/store/modules/runtime'
|
|
import { piniaSettingStore } from '../../src/store/modules/setting'
|
|
|
|
it('lets a custom header replace the complete default header and top navigation', () => {
|
|
const pinia = createPinia()
|
|
|
|
setActivePinia(pinia)
|
|
piniaSettingStore().updateSettingState('layoutConfig', { mode: 'top' })
|
|
const options = {
|
|
global: { renderStubDefaultSlot: true, plugins: [router, pinia] },
|
|
}
|
|
const standard = shallowMount(Layout, options)
|
|
|
|
expect(standard.find('top-navigation-stub').exists()).toBe(true)
|
|
standard.unmount()
|
|
const custom = shallowMount(Layout, {
|
|
...options,
|
|
slots: {
|
|
header: () => h('div', { 'data-test': 'custom-header' }, 'Custom'),
|
|
},
|
|
})
|
|
|
|
try {
|
|
expect(custom.find('[data-test="custom-header"]').exists()).toBe(true)
|
|
expect(custom.find('top-navigation-stub').exists()).toBe(false)
|
|
} finally {
|
|
custom.unmount()
|
|
disposePinia(pinia)
|
|
}
|
|
})
|
|
|
|
it('offers a restore button for custom content and also exits with Escape', async () => {
|
|
const pinia = createPinia()
|
|
|
|
setActivePinia(pinia)
|
|
const runtime = piniaRuntimeStore()
|
|
const wrapper = shallowMount(Layout, {
|
|
global: { renderStubDefaultSlot: true, plugins: [router, pinia] },
|
|
slots: {
|
|
default: () => h('div', { 'data-test': 'custom-content' }, 'Custom'),
|
|
},
|
|
})
|
|
|
|
try {
|
|
expect(wrapper.find('.r-layout-content-restore__button').exists()).toBe(
|
|
false,
|
|
)
|
|
runtime.setRuntimeState('layoutContentMaximize', true)
|
|
await nextTick()
|
|
expect(wrapper.find('[data-test="custom-content"]').exists()).toBe(true)
|
|
await wrapper.get('.r-layout-content-restore__button').trigger('click')
|
|
expect(runtime.layoutContentMaximize).toBe(false)
|
|
|
|
runtime.setRuntimeState('layoutContentMaximize', true)
|
|
await nextTick()
|
|
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }))
|
|
expect(runtime.layoutContentMaximize).toBe(false)
|
|
} finally {
|
|
wrapper.unmount()
|
|
disposePinia(pinia)
|
|
}
|
|
})
|