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';
|
|
|
|
|
|
|
|
describe('VnLog', () => {
|
|
|
|
let vm;
|
|
|
|
beforeAll(() => {
|
|
|
|
vm = createWrapper(VnLog, {
|
2023-04-20 06:25:06 +00:00
|
|
|
global: {
|
|
|
|
stubs: ['FetchData', 'VnPaginate'],
|
|
|
|
mocks: {
|
|
|
|
fetch: vi.fn(),
|
|
|
|
},
|
|
|
|
},
|
2023-04-18 12:43:18 +00:00
|
|
|
propsData: {
|
|
|
|
model: "Claim",
|
|
|
|
},
|
|
|
|
}).vm;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vi.clearAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('formatValue()', () => {
|
|
|
|
it('should return Yes if has a true boolean', async () => {
|
|
|
|
const result = vm.formatValue(true);
|
|
|
|
|
|
|
|
expect(result).toEqual('Yes');
|
|
|
|
});
|
|
|
|
it('should return No if has a true boolean', async () => {
|
|
|
|
const result = vm.formatValue(false);
|
|
|
|
|
|
|
|
expect(result).toEqual('No');
|
|
|
|
});
|
|
|
|
it('should return Nothing if has no params', async () => {
|
|
|
|
const result = vm.formatValue();
|
|
|
|
|
|
|
|
expect(result).toEqual('Nothing');
|
|
|
|
});
|
|
|
|
it('should return a string from a string value', async () => {
|
|
|
|
const result = vm.formatValue('Something');
|
|
|
|
|
|
|
|
expect(result).toEqual(`"Something"`);
|
|
|
|
});
|
|
|
|
it('should call to format a date', async () => {
|
|
|
|
vi.mock('src/filters', () => ({
|
|
|
|
toDate: ()=>{
|
|
|
|
return "Date formatted"
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
const result = vm.formatValue('01-01-1970');
|
|
|
|
expect(result).toEqual("Date formatted");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('actionColor()', () => {
|
|
|
|
it('should return positive if insert', async () => {
|
|
|
|
const result = vm.actionColor('insert');
|
|
|
|
|
|
|
|
expect(result).toEqual('positive');
|
|
|
|
});
|
|
|
|
it('should return positive if update', async () => {
|
|
|
|
const result = vm.actionColor('update');
|
|
|
|
|
|
|
|
expect(result).toEqual('positive');
|
|
|
|
});
|
|
|
|
it('should return negative if delete', async () => {
|
|
|
|
const result = vm.actionColor('delete');
|
|
|
|
|
|
|
|
expect(result).toEqual('negative');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|