This commit is contained in:
parent
5ef5285abc
commit
d5639471cf
|
@ -0,0 +1,47 @@
|
||||||
|
import { describe, expect, it, beforeAll, beforeEach } from 'vitest';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
|
||||||
|
describe('VnTable', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vm;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
wrapper = createWrapper(VnTable, {
|
||||||
|
propsData: {
|
||||||
|
columns: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
vm = wrapper.vm;
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => (vm.selected = []));
|
||||||
|
|
||||||
|
describe('handleSelection()', () => {
|
||||||
|
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
|
||||||
|
const selectedRows = [{ $index: 1 }];
|
||||||
|
it('should add rows to selected when shift key is pressed and rows are added', () => {
|
||||||
|
vm.handleSelection(
|
||||||
|
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
||||||
|
rows
|
||||||
|
);
|
||||||
|
expect(vm.selected).toEqual([{ $index: 0 }, { $index: 1 }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add rows to selected when shift key is not pressed', () => {
|
||||||
|
vm.handleSelection(
|
||||||
|
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
||||||
|
rows
|
||||||
|
);
|
||||||
|
expect(vm.selected).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add rows to selected when rows are not added', () => {
|
||||||
|
vm.handleSelection(
|
||||||
|
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
||||||
|
rows
|
||||||
|
);
|
||||||
|
expect(vm.selected).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue