Introduce prettier
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { UserType } from "@/types/user";
|
||||
import { avatars } from "@/config/selection";
|
||||
import Config from "@/config/config";
|
||||
import { UserType } from '@/types/user';
|
||||
import { avatars } from '@/config/selection';
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
async function signUp(newUser: UserType) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newUser),
|
||||
};
|
||||
@@ -22,16 +22,16 @@ async function signUp(newUser: UserType) {
|
||||
const token = await response.json();
|
||||
return token;
|
||||
} catch (error: any) {
|
||||
console.error("Error sign up:", error);
|
||||
console.error('Error sign up:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function signIn(signInUser: UserType) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(signInUser),
|
||||
};
|
||||
@@ -46,7 +46,7 @@ async function signIn(signInUser: UserType) {
|
||||
const token = await response.json();
|
||||
return token;
|
||||
} catch (error: any) {
|
||||
console.error("Error sign in:", error);
|
||||
console.error('Error sign in:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { isValidEmail, isValidPassword } from "./validate";
|
||||
import { expect, test } from 'vitest';
|
||||
import { isValidEmail, isValidPassword } from './validate';
|
||||
|
||||
test("validate email", () => {
|
||||
const email1 = "aaa@gmail.com";
|
||||
test('validate email', () => {
|
||||
const email1 = 'aaa@gmail.com';
|
||||
expect(isValidEmail(email1)).toBe(true);
|
||||
|
||||
const email2 = "gmail.com";
|
||||
const email2 = 'gmail.com';
|
||||
expect(isValidEmail(email2)).toBe(false);
|
||||
|
||||
const email23 = "";
|
||||
const email23 = '';
|
||||
expect(isValidEmail(email23)).toBe(false);
|
||||
});
|
||||
|
||||
test("validate password", () => {
|
||||
const pass1 = "aaaaaaaa";
|
||||
test('validate password', () => {
|
||||
const pass1 = 'aaaaaaaa';
|
||||
expect(isValidPassword(pass1)).toBe(true);
|
||||
|
||||
const pass2 = "abcdefg";
|
||||
const pass2 = 'abcdefg';
|
||||
expect(isValidPassword(pass2)).toBe(false);
|
||||
|
||||
const pass3 = "";
|
||||
const pass3 = '';
|
||||
expect(isValidPassword(pass3)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
function isValidEmail(email: string) {
|
||||
const validRegex =
|
||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
||||
const validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
||||
if (email.match(validRegex)) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user