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

62 lines
1.4 KiB
Rust
Raw Normal View History

use crate::helper::*;
use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*};
2021-07-11 09:38:03 +00:00
use serial_test::*;
#[test]
2021-07-11 09:38:03 +00:00
#[serial]
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)
.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(),
};
assert_eq!(
2021-07-14 15:00:58 +00:00
UserTestBuilder::new()
.event(SignIn)
.request(request)
.sync_send()
.error()
.code,
UserErrorCode::EmailInvalid
);
}
}
#[test]
fn sign_in_with_invalid_password() {
for password in invalid_password_test_case() {
let request = SignInRequest {
email: valid_email(),
password,
};
assert_eq!(
2021-07-14 15:00:58 +00:00
UserTestBuilder::new()
.event(SignIn)
.request(request)
.sync_send()
.error()
.code,
UserErrorCode::PasswordInvalid
);
}
}