This commit is contained in:
2026-08-10 16:24:54 +08:00
parent e119b48662
commit 820432a381
52 changed files with 1015 additions and 705 deletions
+25 -3
View File
@@ -94,7 +94,7 @@ describe('DataTable column preferences', () => {
slots: {
'toolbar-start': '<h2>订单列表</h2>',
'toolbar-actions': '<button>新增订单</button>',
'toolbar-end': '<button>刷新</button>',
'toolbar-end': '<button>辅助操作</button>',
},
global: {
provide: { [UI_PREFERENCE_SCOPE as symbol]: computed(() => 'user-1') },
@@ -109,10 +109,32 @@ describe('DataTable column preferences', () => {
})
expect(wrapper.findAll('.data-table__toolbar')).toHaveLength(1)
expect(wrapper.get('.data-table__toolbar').classes()).not.toContain('is-compact')
expect(wrapper.get('.data-table__toolbar-start').text()).toBe('订单列表')
expect(wrapper.get('.data-table__toolbar-actions').text()).toContain('新增订单')
expect(wrapper.get('.data-table__toolbar-actions').text()).toContain('刷新')
expect(wrapper.get('.data-table__toolbar-actions').text()).toContain('辅助操作')
expect(wrapper.get('.data-table__business-actions').text()).toBe('新增订单')
expect(wrapper.get('.data-table__toolbar-end').text()).toBe('辅助操作')
})
it('uses a compact right-aligned toolbar when no leading content is provided', () => {
const wrapper = shallowMount(DataTable, {
props: { data: [], columns: configurableColumns, preferenceKey: 'orders-table' },
slots: { 'toolbar-actions': '<button>新增订单</button>' },
global: {
provide: { [UI_PREFERENCE_SCOPE as symbol]: computed(() => 'user-1') },
stubs: {
ElTable: TableStub,
ElTableColumn: ColumnStub,
ElButton: ButtonStub,
ElPopover: PopoverStub,
},
directives: { loading: {} },
},
})
expect(wrapper.get('.data-table__toolbar').classes()).toContain('is-compact')
expect(wrapper.find('.data-table__toolbar-start').exists()).toBe(false)
expect(wrapper.get('.data-table__business-actions').text()).toBe('新增订单')
expect(wrapper.get('.data-table__toolbar-end').text()).toBe('刷新')
})
})