test: refs #8647 fix warning

This commit is contained in:
Javier Segarra 2025-02-28 09:42:11 +01:00
parent 29cd014ec8
commit a6777cc183
6 changed files with 34 additions and 18 deletions

View File

@ -4,7 +4,7 @@ import VnDiscount from 'components/common/vnDiscount.vue';
describe('VnDiscount', () => { describe('VnDiscount', () => {
let vm; let vm;
beforeAll(() => { beforeAll(() => {
vm = createWrapper(VnDiscount, { vm = createWrapper(VnDiscount, {
props: { props: {
@ -12,7 +12,9 @@ describe('VnDiscount', () => {
price: 100, price: 100,
quantity: 2, quantity: 2,
discount: 10, discount: 10,
} mana: 10,
promise: vi.fn(),
},
}).vm; }).vm;
}); });
@ -21,8 +23,8 @@ describe('VnDiscount', () => {
}); });
describe('total', () => { describe('total', () => {
it('should calculate total correctly', () => { it('should calculate total correctly', () => {
expect(vm.total).toBe(180); expect(vm.total).toBe(180);
}); });
}); });
}); });

View File

@ -23,7 +23,7 @@ const claimDms = ref([
]); ]);
const client = ref({}); const client = ref({});
const inputFile = ref(); const inputFile = ref();
const files = ref({}); const files = ref([]);
const spinnerRef = ref(); const spinnerRef = ref();
const claimDmsRef = ref(); const claimDmsRef = ref();
const dmsType = ref({}); const dmsType = ref({});
@ -252,9 +252,8 @@ function onDrag() {
icon="add" icon="add"
color="primary" color="primary"
> >
<QInput <QFile
ref="inputFile" ref="inputFile"
type="file"
style="display: none" style="display: none"
multiple multiple
v-model="files" v-model="files"

View File

@ -1,6 +1,7 @@
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest'; import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper'; import { createWrapper, axios } from 'app/test/vitest/helper';
import ClaimLines from '/src/pages/Claim/Card/ClaimLines.vue'; import ClaimLines from '/src/pages/Claim/Card/ClaimLines.vue';
import keyShortcut from 'src/boot/keyShortcut';
describe('ClaimLines', () => { describe('ClaimLines', () => {
let vm; let vm;
@ -12,6 +13,9 @@ describe('ClaimLines', () => {
mocks: { mocks: {
fetch: vi.fn(), fetch: vi.fn(),
}, },
directives: {
shortcut: keyShortcut,
},
}, },
}).vm; }).vm;
}); });
@ -51,7 +55,7 @@ describe('ClaimLines', () => {
expectedData, expectedData,
{ {
signal: canceller.signal, signal: canceller.signal,
} },
); );
}); });
}); });
@ -68,7 +72,7 @@ describe('ClaimLines', () => {
expect.objectContaining({ expect.objectContaining({
message: 'Discount updated', message: 'Discount updated',
type: 'positive', type: 'positive',
}) }),
); );
}); });
}); });

View File

@ -1,4 +1,4 @@
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest'; import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper'; import { createWrapper, axios } from 'app/test/vitest/helper';
import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue'; import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue';
@ -13,6 +13,9 @@ describe('ClaimLinesImport', () => {
fetch: vi.fn(), fetch: vi.fn(),
}, },
}, },
propsData: {
ticketId: 1,
},
}).vm; }).vm;
}); });
@ -39,7 +42,7 @@ describe('ClaimLinesImport', () => {
expect.objectContaining({ expect.objectContaining({
message: 'Lines added to claim', message: 'Lines added to claim',
type: 'positive', type: 'positive',
}) }),
); );
expect(vm.canceller).toEqual(null); expect(vm.canceller).toEqual(null);
}); });

View File

@ -1,6 +1,7 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper'; import { createWrapper, axios } from 'app/test/vitest/helper';
import ClaimPhoto from 'pages/Claim/Card/ClaimPhoto.vue'; import ClaimPhoto from 'pages/Claim/Card/ClaimPhoto.vue';
import keyShortcut from 'src/boot/keyShortcut';
describe('ClaimPhoto', () => { describe('ClaimPhoto', () => {
let vm; let vm;
@ -25,6 +26,9 @@ describe('ClaimPhoto', () => {
mocks: { mocks: {
fetch: vi.fn(), fetch: vi.fn(),
}, },
directives: {
shortcut: keyShortcut,
},
}, },
}).vm; }).vm;
}); });
@ -41,10 +45,10 @@ describe('ClaimPhoto', () => {
await vm.deleteDms({ index: 0 }); await vm.deleteDms({ index: 0 });
expect(axios.post).toHaveBeenCalledWith( expect(axios.post).toHaveBeenCalledWith(
`ClaimDms/${claimMock.claimDms[0].dmsFk}/removeFile` `ClaimDms/${claimMock.claimDms[0].dmsFk}/removeFile`,
); );
expect(vm.quasar.notify).toHaveBeenCalledWith( expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' }) expect.objectContaining({ type: 'positive' }),
); );
}); });
}); });
@ -61,9 +65,9 @@ describe('ClaimPhoto', () => {
title: 'This file will be deleted', title: 'This file will be deleted',
icon: 'delete', icon: 'delete',
data: { index: 1 }, data: { index: 1 },
promise: vm.deleteDms promise: vm.deleteDms,
}, },
}) }),
); );
}); });
}); });
@ -102,10 +106,10 @@ describe('ClaimPhoto', () => {
new FormData(), new FormData(),
expect.objectContaining({ expect.objectContaining({
params: expect.objectContaining({ hasFile: false }), params: expect.objectContaining({ hasFile: false }),
}) }),
); );
expect(vm.quasar.notify).toHaveBeenCalledWith( expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' }) expect.objectContaining({ type: 'positive' }),
); );
expect(vm.claimDmsRef.fetch).toHaveBeenCalledOnce(); expect(vm.claimDmsRef.fetch).toHaveBeenCalledOnce();

View File

@ -1,6 +1,7 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper'; import { createWrapper, axios } from 'app/test/vitest/helper';
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue'; import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
import keyShortcut from 'src/boot/keyShortcut';
describe('CustomerPayments', () => { describe('CustomerPayments', () => {
let vm; let vm;
@ -12,6 +13,9 @@ describe('CustomerPayments', () => {
mocks: { mocks: {
fetch: vi.fn(), fetch: vi.fn(),
}, },
directives: {
shortcut: keyShortcut,
},
}, },
}).vm; }).vm;
}); });
@ -31,7 +35,7 @@ describe('CustomerPayments', () => {
expect.objectContaining({ expect.objectContaining({
message: 'Payment confirmed', message: 'Payment confirmed',
type: 'positive', type: 'positive',
}) }),
); );
}); });
}); });