-
-
Save AllGistsEqual/f12a14b4e3f29537ae67d5e17a28ab45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mockCheckLoginData = (email: string, password: string): boolean => | |
fakeUserData.filter(data => data.email === email && data.password === password).length > 0 | |
export const login = ( | |
email: string, | |
password: string, | |
shouldFail = false, | |
): Promise<mockRequestValue> => { | |
if (shouldFail) { | |
return mockFailure({ error: 500, message: 'Request failed successfully!' }) | |
} | |
if (!mockCheckLoginData(email, password)) { | |
return mockFailure({ | |
error: 401, | |
message: 'Login failed, email or password did not match!', | |
}) | |
} | |
return mockSuccess({ authToken: 'mock_token_value' }) | |
} | |
export const createAccount = ( | |
email: string, | |
password: string, | |
shouldFail = false, | |
): Promise<mockRequestValue> => { | |
if (shouldFail) { | |
return mockFailure({ error: 500, message: 'Request failed successfully!' }) | |
} | |
return mockSuccess({ authToken: 'mock_token_value' }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment