forked from verdnatura/salix-front
feat: refs #7702 test wip
This commit is contained in:
parent
91dccd10d3
commit
b015397822
|
@ -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');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue