AppFlowy/rust-lib/flowy-user/tests/event/sign_in_test.rs
2021-08-24 13:23:19 +08:00

59 lines
1.3 KiB
Rust

use crate::helper::*;
use flowy_user::{errors::UserErrCode, event::UserEvent::*, prelude::*};
use serial_test::*;
#[test]
#[serial]
fn sign_in_success() {
let request = SignInRequest {
email: random_valid_email(),
password: valid_password(),
};
let response = UserTestBuilder::new()
.logout()
.event(SignIn)
.request(request)
.sync_send()
.parse::<UserDetail>();
dbg!(&response);
}
#[test]
#[serial]
fn sign_in_with_invalid_email() {
for email in invalid_email_test_case() {
let request = SignInRequest {
email: email.to_string(),
password: valid_password(),
};
assert_eq!(
UserTestBuilder::new()
.event(SignIn)
.request(request)
.sync_send()
.error()
.code,
UserErrCode::EmailFormatInvalid
);
}
}
#[test]
#[serial]
fn sign_in_with_invalid_password() {
for password in invalid_password_test_case() {
let request = SignInRequest {
email: random_valid_email(),
password,
};
UserTestBuilder::new()
.event(SignIn)
.request(request)
.sync_send()
.assert_error();
}
}