Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created April 25, 2021 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/f12a14b4e3f29537ae67d5e17a28ab45 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/f12a14b4e3f29537ae67d5e17a28ab45 to your computer and use it in GitHub Desktop.
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