salix-front/test/vitest/__tests__/components/common/VnLog.spec.js

132 lines
3.7 KiB
JavaScript
Raw Normal View History

2023-04-20 06:25:06 +00:00
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
2023-04-18 12:43:18 +00:00
import VnLog from 'src/components/common/VnLog.vue';
const mockValidations = {
Claim: {
locale: {
name: 'reclamación',
},
},
ClaimObservation: {
locale: {
name: 'observación',
},
},
ClaimDms: {
locale: {
name: 'documento',
},
},
ClaimBeginning: {
locale: {
name: 'comienzo',
},
},
};
2023-04-18 12:43:18 +00:00
describe('VnLog', () => {
let vm;
2023-04-18 12:43:18 +00:00
beforeAll(() => {
vm = createWrapper(VnLog, {
2023-04-20 06:25:06 +00:00
global: {
stubs: [],
mocks: {},
2023-04-20 06:25:06 +00:00
},
2023-04-18 12:43:18 +00:00
propsData: {
model: 'Claim',
2023-04-18 12:43:18 +00:00
},
}).vm;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should correctly set logTree', async () => {
const fakeLogTreeData = [
{
id: 2,
originFk: 1,
userFk: 18,
action: 'update',
changedModel: 'ClaimObservation',
oldInstance: {},
newInstance: {
claimFk: 1,
text: 'Waiting for customer',
2023-04-18 12:43:18 +00:00
},
creationDate: '2023-09-18T12:25:34.000Z',
changedModelId: '1',
changedModelValue: null,
description: null,
user: {
id: 18,
name: 'salesPerson',
nickname: 'salesPersonNick',
image: '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd',
worker: {
id: 18,
userFk: 18,
},
},
},
{
id: 1,
originFk: 1,
userFk: 18,
action: 'update',
changedModel: 'Claim',
oldInstance: {
hasToPickUp: false,
},
newInstance: {
hasToPickUp: true,
},
creationDate: '2023-09-18T12:25:34.000Z',
changedModelId: '1',
changedModelValue: null,
description: null,
user: {
id: 18,
name: 'salesPerson',
nickname: 'salesPersonNick',
image: '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd',
worker: {
id: 18,
userFk: 18,
},
},
},
];
vm.validations = mockValidations;
vm.logTree = vm.getLogs(fakeLogTreeData);
expect(vm.logTree[0].originFk).toEqual(1);
expect(vm.logTree[0].logs[0].user.name).toEqual('salesPerson');
2023-04-18 12:43:18 +00:00
});
it('should correctly set the selectedFilters when filtering', async () => {
await vm.$nextTick();
vm.searchInput = '1';
vm.userSelect = '21';
vm.checkboxOptions.insert.selected = true;
vm.checkboxOptions.update.selected = true;
2023-04-18 12:43:18 +00:00
vm.selectFilter('search');
vm.selectFilter('userSelect');
2023-04-18 12:43:18 +00:00
expect(vm.selectedFilters.changedModelId).toEqual('1');
expect(vm.selectedFilters.userFk).toEqual('21');
expect(vm.selectedFilters.action).toEqual({ inq: ['insert', 'update'] });
});
2023-04-18 12:43:18 +00:00
2023-09-28 11:45:14 +00:00
/*it('should correctly set the date from', () => {
vm.date = '18-09-2023';
vm.selectFilter('date', 'from');
expect(vm.selectedFilters.creationDate).toEqual({
between: ['2023-09-18T00:00:00.000Z', '2023-09-18T19:59:59.999Z'],
2023-04-18 12:43:18 +00:00
});
2023-09-28 11:45:14 +00:00
}); */
2023-04-18 12:43:18 +00:00
});