AppFlowy/rust-lib/flowy-user/tests/event/user_status_test.rs

63 lines
1.4 KiB
Rust
Raw Normal View History

use crate::helper::*;
use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*};
use serial_test::*;
#[test]
2021-07-11 09:38:03 +00:00
#[should_panic]
#[serial]
2021-07-11 09:38:03 +00:00
fn user_status_not_found_before_login() {
2021-07-14 15:00:58 +00:00
let _ = UserTestBuilder::new()
.logout()
.event(GetStatus)
2021-07-11 09:38:03 +00:00
.sync_send()
.parse::<UserDetail>();
}
#[test]
#[serial]
2021-07-11 09:38:03 +00:00
fn user_status_did_found_after_login() {
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 09:38:03 +00:00
.request(request)
.sync_send()
.parse::<UserDetail>();
dbg!(&response);
2021-07-14 15:00:58 +00:00
let _ = UserTestBuilder::new()
.event(GetStatus)
2021-07-11 09:38:03 +00:00
.sync_send()
.parse::<UserDetail>();
}
#[test]
#[serial]
fn user_update_with_invalid_email() {
2021-07-14 15:00:58 +00:00
let user_detail = UserTestBuilder::new().login().user_detail.unwrap();
for email in invalid_email_test_case() {
let request = UpdateUserRequest {
id: user_detail.id.clone(),
name: None,
email: Some(email),
workspace: None,
password: None,
};
assert_eq!(
2021-07-14 15:00:58 +00:00
UserTestBuilder::new()
.event(UpdateUser)
.request(request)
.sync_send()
.error()
.code,
UserErrorCode::EmailInvalid
);
}
}