0
0
Fork 0

feat: refs #7702 test wip

This commit is contained in:
Jorge Penadés 2024-09-16 10:59:32 +02:00
parent 91dccd10d3
commit b015397822
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import { createWrapper } from 'app/test/vitest/helper';
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
describe('VnSmsDialog', () => {
let vm;
beforeAll(() => {
vm = createWrapper(VnChangePassword, {
propsData: {
submitFn: vi.fn(),
},
}).vm;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should notify when new password is empty', async () => {
vm.passwords.newPassword = '';
vm.passwords.repeatPassword = 'password';
vi.spyOn(vm, 'notify');
await vm.validate();
expect(vm.notify).toHaveBeenCalledWith(
expect.arguments({
message: 'You must enter a new password',
type: 'negative',
})
);
});
it("should notify when passwords don't match", async () => {
vm.passwords.newPassword = 'password1';
vm.passwords.repeatPassword = 'password2';
vi.spyOn(vm, 'notify');
await vm.validate();
expect(vm.notify).toHaveBeenCalledWith("Passwords don't match", 'negative');
});
it('should call submitFn and emit onSubmit when passwords match', async () => {
vm.passwords.newPassword = 'password';
vm.passwords.repeatPassword = 'password';
await vm.validate();
expect(vm.props.submitFn).toHaveBeenCalledWith('password');
});
});