test: add test to ensure row is not selected when inner button is clicked

pull/6544/head
KumJungMin 2024-10-09 14:23:20 +09:00
parent c2a5378b9d
commit f71e839ac9
1 changed files with 42 additions and 0 deletions

View File

@ -582,6 +582,48 @@ describe('DataTable.vue', () => {
expect(wrapper.emitted()['row-select'][1][0].index).toBe(1);
});
it('should not select row when inner button is clicked', async () => {
wrapper = mount(DataTable, {
global: {
plugins: [PrimeVue],
components: {
Column,
Button
}
},
props: {
value: smallData,
expandedRows: [],
paginatorTemplate: 'CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
rowsPerPageOptions: [5, 6, 7],
currentPageReportTemplate: 'Showing {first} to {last} of {totalRecords}'
},
slots: {
default: `
<Column :expander="true" />
<Column field="code" header="Code" sortable>
<template #body="slotProps">
<button @click="buttonClicked">button</button>
</template>
</Column>
<Column field="name" header="Name" sortable></Column>
`
},
methods: {
buttonClicked() {
console.log('button clicked');
}
}
});
const button = wrapper.find('button');
expect(button.exists()).toBe(true);
await button.trigger('click');
expect(wrapper.emitted()['row-click']).toBeUndefined();
});
it('should select all rows', async () => {
wrapper = mount(DataTable, {
global: {