2021-07-11 07:33:19 +00:00
|
|
|
use crate::helper::*;
|
2021-07-14 13:12:52 +00:00
|
|
|
|
|
|
|
use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*};
|
2021-07-11 09:38:03 +00:00
|
|
|
use serial_test::*;
|
|
|
|
|
2021-07-11 07:33:19 +00:00
|
|
|
#[test]
|
2021-07-11 09:38:03 +00:00
|
|
|
#[serial]
|
2021-07-11 07:33:19 +00:00
|
|
|
fn sign_in_success() {
|
|
|
|
let request = SignInRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-07-14 15:00:58 +00:00
|
|
|
let response = UserTestBuilder::new()
|
|
|
|
.logout()
|
|
|
|
.event(SignIn)
|
2021-07-11 07:33:19 +00:00
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.parse::<UserDetail>();
|
|
|
|
dbg!(&response);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sign_in_with_invalid_email() {
|
|
|
|
for email in invalid_email_test_case() {
|
|
|
|
let request = SignInRequest {
|
|
|
|
email: email.to_string(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-07-11 13:54:55 +00:00
|
|
|
assert_eq!(
|
2021-07-14 15:00:58 +00:00
|
|
|
UserTestBuilder::new()
|
|
|
|
.event(SignIn)
|
2021-07-11 13:54:55 +00:00
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
2021-07-14 00:23:35 +00:00
|
|
|
.error()
|
2021-07-11 13:54:55 +00:00
|
|
|
.code,
|
|
|
|
UserErrorCode::EmailInvalid
|
|
|
|
);
|
2021-07-11 07:33:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sign_in_with_invalid_password() {
|
|
|
|
for password in invalid_password_test_case() {
|
|
|
|
let request = SignInRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
password,
|
|
|
|
};
|
|
|
|
|
2021-07-11 13:54:55 +00:00
|
|
|
assert_eq!(
|
2021-07-14 15:00:58 +00:00
|
|
|
UserTestBuilder::new()
|
|
|
|
.event(SignIn)
|
2021-07-11 13:54:55 +00:00
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
2021-07-14 00:23:35 +00:00
|
|
|
.error()
|
2021-07-11 13:54:55 +00:00
|
|
|
.code,
|
|
|
|
UserErrorCode::PasswordInvalid
|
|
|
|
);
|
2021-07-11 07:33:19 +00:00
|
|
|
}
|
|
|
|
}
|