Skip to content

Commit

Permalink
fix: missing vi import
Browse files Browse the repository at this point in the history
  • Loading branch information
LeleDallas committed May 2, 2023
1 parent 9b4cd2d commit 0f2343c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/componentsFunctions.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { vi } from "vitest";
import { handleLoginSubmit, handleSignUpSubmit, signInButton, signUpButton } from "../src/componentsFunctions";

describe('Authentication functions', () => {
describe('signUpButton', () => {
it('should call the setError and setSwapPanel functions with the correct arguments', () => {
const setError = jest.fn();
const setSwapPanel = jest.fn();
const setError = vi.fn();
const setSwapPanel = vi.fn();
signUpButton(setError, setSwapPanel);
expect(setError).toHaveBeenCalledWith([]);
expect(setSwapPanel).toHaveBeenCalledWith(true);
Expand All @@ -13,8 +14,8 @@ describe('Authentication functions', () => {

describe('signInButton', () => {
it('should call the setError and setSwapPanel functions with the correct arguments', () => {
const setError = jest.fn();
const setSwapPanel = jest.fn();
const setError = vi.fn();
const setSwapPanel = vi.fn();
signInButton(setError, setSwapPanel);
expect(setError).toHaveBeenCalledWith([]);
expect(setSwapPanel).toHaveBeenCalledWith(false);
Expand All @@ -23,23 +24,23 @@ describe('Authentication functions', () => {

describe('handleLoginSubmit', () => {
it('should call setError with an error message if email or password is null', () => {
const setError = jest.fn();
const setError = vi.fn();
handleLoginSubmit("", 'password', setError);
expect(setError).toHaveBeenCalledWith(['Fill the form to continue']);
handleLoginSubmit('email', "", setError);
expect(setError).toHaveBeenCalledWith(['Fill the form to continue']);
});

it('should not call setError if email and password are not null', () => {
const setError = jest.fn();
const setError = vi.fn();
handleLoginSubmit('email', 'password', setError);
expect(setError).not.toHaveBeenCalled();
});
});

describe('handleSignUpSubmit', () => {
it('should call setError with an error message if any required fields are null', () => {
const setError = jest.fn();
const setError = vi.fn();
handleSignUpSubmit(null, 'name', 'surname', 'password', 'password', 'email', 'type', setError);
expect(setError).toHaveBeenCalledWith(['Fill the form to continue']);
handleSignUpSubmit('event', "", 'surname', 'password', 'password', 'email', 'type', setError);
Expand All @@ -55,13 +56,13 @@ describe('Authentication functions', () => {
});

it('should call setError with an error message if password and passwordConf do not match', () => {
const setError = jest.fn();
const setError = vi.fn();
handleSignUpSubmit('event', 'name', 'surname', 'password', 'different', 'email', 'type', setError);
expect(setError).toHaveBeenCalledWith(['Typed Password are different']);
});

it('should not call setError if all required fields are present and password and passwordConf match', () => {
const setError = jest.fn();
const setError = vi.fn();
handleSignUpSubmit('event', 'name', 'surname', 'password', 'password', 'email', 'type', setError);
expect(setError).not.toHaveBeenCalled();
});
Expand Down

0 comments on commit 0f2343c

Please sign in to comment.