8713-testToMaster #1539

Merged
alexm merged 118 commits from 8713-testToMaster into master 2025-03-04 06:57:15 +00:00
1 changed files with 35 additions and 29 deletions
Showing only changes of commit a7af697947 - Show all commits

View File

@ -30,8 +30,8 @@ describe('CrudModel', () => {
saveFn: '', saveFn: '',
}, },
}); });
wrapper=wrapper.wrapper; wrapper = wrapper.wrapper;
vm=wrapper.vm; vm = wrapper.vm;
}); });
beforeEach(() => { beforeEach(() => {
@ -143,14 +143,14 @@ describe('CrudModel', () => {
}); });
it('should return true if object is empty', async () => { it('should return true if object is empty', async () => {
dummyObj ={}; dummyObj = {};
result = vm.isEmpty(dummyObj); result = vm.isEmpty(dummyObj);
expect(result).toBe(true); expect(result).toBe(true);
}); });
it('should return false if object is not empty', async () => { it('should return false if object is not empty', async () => {
dummyObj = {a:1, b:2, c:3}; dummyObj = { a: 1, b: 2, c: 3 };
result = vm.isEmpty(dummyObj); result = vm.isEmpty(dummyObj);
expect(result).toBe(false); expect(result).toBe(false);
@ -164,20 +164,22 @@ describe('CrudModel', () => {
}); });
it('should return false if array is not empty', async () => { it('should return false if array is not empty', async () => {
dummyArray = [1,2,3]; dummyArray = [1, 2, 3];
result = vm.isEmpty(dummyArray); result = vm.isEmpty(dummyArray);
expect(result).toBe(false); expect(result).toBe(false);
}) });
}); });
describe('resetData()', () => { describe('resetData()', () => {
it('should add $index to elements in data[] and sets originalData and formData with data', async () => { it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
data = [{ data = [
{
name: 'Tony', name: 'Tony',
lastName: 'Stark', lastName: 'Stark',
age: 42, age: 42,
}]; },
];
vm.resetData(data); vm.resetData(data);
@ -210,11 +212,13 @@ describe('CrudModel', () => {
}); });
describe('saveChanges()', () => { describe('saveChanges()', () => {
data = [{ data = [
{
name: 'Tony', name: 'Tony',
lastName: 'Stark', lastName: 'Stark',
age: 42, age: 42,
}]; },
];
it('should call saveFn if exists', async () => { it('should call saveFn if exists', async () => {
await wrapper.setProps({ saveFn: vi.fn() }); await wrapper.setProps({ saveFn: vi.fn() });
@ -229,13 +233,15 @@ describe('CrudModel', () => {
}); });
it("should use default url if there's not saveFn", async () => { it("should use default url if there's not saveFn", async () => {
const postMock =vi.spyOn(axios, 'post'); const postMock = vi.spyOn(axios, 'post');
vm.formData = [{ vm.formData = [
{
name: 'Bruce', name: 'Bruce',
lastName: 'Wayne', lastName: 'Wayne',
age: 45, age: 45,
}] },
];
await vm.saveChanges(data); await vm.saveChanges(data);