#7050 testCrudModel #1077

Merged
jtubau merged 11 commits from 7050-testCrudModel into dev 2024-12-26 11:14:16 +00:00
1 changed files with 44 additions and 0 deletions
Showing only changes of commit c164c39a2d - Show all commits

View File

@ -1,5 +1,6 @@
import { createWrapper } from 'app/test/vitest/helper';
import CrudModel from 'components/CrudModel.vue';
import c from 'croppie';
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
describe('CrudModel', () => {
@ -117,4 +118,47 @@ describe('CrudModel', () => {
});
});
});
describe('isEmpty()', () => {
let dummyObj;
let dummyArray;
let result;
it('should return true if object si null', async () => {
dummyObj = null;
result = vm.isEmpty(dummyObj);
expect(result).toBe(true);
});
it('should return true if object si undefined', async () => {
dummyObj = undefined;
result = vm.isEmpty(dummyObj);
expect(result).toBe(true);
});
it('should return true if object is empty', async () => {
jtubau marked this conversation as resolved Outdated

Falta comprobar si es array vacío o lleno

Falta comprobar si es array vacío o lleno

estaban hechos pero los puse dentro del mismo it para comprobar el objeto, los he separado para mayor claridad.

estaban hechos pero los puse dentro del mismo **it** para comprobar el objeto, los he separado para mayor claridad.
dummyObj ={};
result = vm.isEmpty(dummyObj);
expect(result).toBe(true);
dummyArray = [];
result = vm.isEmpty(dummyArray);
expect(result).toBe(true);
});
it('should return false if object is not empty', async () => {
dummyObj = {a:1, b:2, c:3};
result = vm.isEmpty(dummyObj);
expect(result).toBe(false);
dummyArray = [1,2,3];
result = vm.isEmpty(dummyArray);
expect(result).toBe(false);
})
});
});