feat: #7103 created test for VnSearchbar #1256

Merged
provira merged 14 commits from 7103-testVnSearchbar into dev 2025-01-22 11:15:21 +00:00
1 changed files with 4 additions and 4 deletions
Showing only changes of commit 2aa7177449 - Show all commits

View File

@ -5,7 +5,6 @@ import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
describe('VnSearchbar', () => { describe('VnSearchbar', () => {
let vm; let vm;
let wrapper; let wrapper;
let applyFilterSpy;
beforeEach(async () => { beforeEach(async () => {
wrapper = createWrapper(VnSearchbar, { wrapper = createWrapper(VnSearchbar, {
@ -21,28 +20,29 @@ describe('VnSearchbar', () => {
vm.searchText = 'Bolas de madera'; vm.searchText = 'Bolas de madera';
vm.arrayData.store.userParams = { staticKey: 'staticValue' }; vm.arrayData.store.userParams = { staticKey: 'staticValue' };
applyFilterSpy = vi.spyOn(vm.arrayData, 'applyFilter').mockImplementation(() => {});
}); });
it('search resets pagination and applies filter', async () => { it('search resets pagination and applies filter', async () => {
const applyFilterSpy = vi.spyOn(vm.arrayData, 'applyFilter').mockImplementation(() => {});
const resetPaginationSpy = vi.spyOn(vm.arrayData, 'resetPagination').mockImplementation(() => {}); const resetPaginationSpy = vi.spyOn(vm.arrayData, 'resetPagination').mockImplementation(() => {});
await vm.search(); await vm.search();
expect(resetPaginationSpy).toHaveBeenCalled(); expect(resetPaginationSpy).toHaveBeenCalled();
expect(applyFilterSpy).toHaveBeenCalledWith({ expect(applyFilterSpy).toHaveBeenCalledWith({
params: { search: 'Bolas de madera' }, params: { search: 'Bolas de madera' },
filter: null,
}); });
}); });
it('search includes static params if searchRemoveParams is false', async () => { it('search includes static params if searchRemoveParams is false', async () => {
const applyFilterSpy = vi.spyOn(vm.arrayData, 'applyFilter').mockImplementation(() => {});
wrapper.setProps({ searchRemoveParams: false }); wrapper.setProps({ searchRemoveParams: false });
await vm.$nextTick(); await vm.$nextTick();
await vm.search(); await vm.search();
expect(applyFilterSpy).toHaveBeenCalledWith({ expect(applyFilterSpy).toHaveBeenCalledWith({
params: { staticKey: 'staticValue', search: 'Bolas de madera' }, params: { staticKey: 'staticValue', search: 'Bolas de madera' },
filter: null, filter: {skip: 0},
}); });
}); });