import { createWrapper } from 'app/test/vitest/helper'; import VnBankDetailsForm from 'components/common/VnBankDetailsForm.vue'; import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest'; describe('VnBankDetail Component', () => { let vm; let wrapper; const bankEntities = [ { id: 2100, bic: 'CAIXESBBXXX', name: 'CaixaBank' }, { id: 1234, bic: 'TESTBIC', name: 'Test Bank' }, ]; const correctIban = 'ES6621000418401234567891'; beforeAll(() => { wrapper = createWrapper(VnBankDetailsForm, { $props: { iban: null, bankEntityFk: null, disableElement: false, }, }); vm = wrapper.vm; wrapper = wrapper.wrapper; }); afterEach(() => { vi.clearAllMocks(); }); it('should update bankEntityFk when IBAN exists in bankEntities', async () => { vm.bankEntities = bankEntities; await vm.autofillBic(correctIban); expect(vm.bankEntityFk).toBe(2100); }); it('should set bankEntityFk to null when IBAN bank code is not found', async () => { vm.bankEntities = bankEntities; await vm.autofillBic('ES1234567891324567891234'); expect(vm.bankEntityFk).toBe(null); }); });