#7056 update route meta information and add FormModel tests #1122
|
@ -112,6 +112,33 @@ describe('FormModel', () => {
|
|||
expect(spy).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should use the saveFn', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, saveFn: () => {} },
|
||||
});
|
||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spyPatch).not.toHaveBeenCalled();
|
||||
expect(spySaveFn).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should reload the data after save', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, reload: true },
|
||||
});
|
||||
vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue