diff --git a/src/components/__tests__/FilterItemForm.spec.js b/src/components/__tests__/FilterItemForm.spec.js index 0c88bf421..210d6bf02 100644 --- a/src/components/__tests__/FilterItemForm.spec.js +++ b/src/components/__tests__/FilterItemForm.spec.js @@ -1,5 +1,5 @@ import { createWrapper, axios } from 'app/test/vitest/helper'; -import FilterItemForm from 'components/FilterItemForm.vue'; +import FilterItemForm from 'src/components/FilterItemForm.vue'; import { vi, beforeAll, describe, expect, it } from 'vitest'; describe('FilterItemForm', () => { @@ -19,7 +19,7 @@ describe('FilterItemForm', () => { data: [ { id: 999996, - name: 'Bolas de madera', + name: 'bolas de madera', size: 2, inkFk: null, producerFk: null, @@ -29,23 +29,26 @@ describe('FilterItemForm', () => { }); it('should filter data and populate tableRows for table display', async () => { - wrapper.setProps({ - itemFilter: { - include: [ - { relation: 'producer', scope: { fields: ['name'] } }, - { relation: 'ink', scope: { fields: ['name'] } }, - ], - where: { name: { like: '%bolas de madera%' } }, - }, - itemFilterParams: { name: 'bolas de madera' }, - }); + vm.itemFilterParams.name = 'bolas de madera'; await vm.onSubmit(); + const expectedFilter = { + include: [ + { relation: 'producer', scope: { fields: ['name'] } }, + { relation: 'ink', scope: { fields: ['name'] } }, + ], + where: {"name":{"like":"%bolas de madera%"}}, + }; + + expect(axios.get).toHaveBeenCalledWith('Items/withName', { + params: { filter: JSON.stringify(expectedFilter) }, + }); + expect(vm.tableRows).toEqual([ { id: 999996, - name: 'Bolas de madera', + name: 'bolas de madera', size: 2, inkFk: null, producerFk: null, @@ -54,6 +57,7 @@ describe('FilterItemForm', () => { }); it('should handle an empty itemFilterParams correctly', async () => { + vm.itemFilterParams.name = null; vm.itemFilterParams = {}; await vm.onSubmit();