2021-07-11 07:33:19 +00:00
|
|
|
use crate::helper::*;
|
|
|
|
use flowy_test::prelude::*;
|
2021-07-11 13:54:55 +00:00
|
|
|
use flowy_user::{errors::*, 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_up_success() {
|
2021-07-14 00:23:35 +00:00
|
|
|
let _ = UserEventTester::new(SignOut).sync_send();
|
2021-07-11 07:33:19 +00:00
|
|
|
let request = SignUpRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
name: valid_name(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-07-14 00:23:35 +00:00
|
|
|
let _response = UserEventTester::new(SignUp).request(request).sync_send();
|
2021-07-11 07:33:19 +00:00
|
|
|
// .parse::<SignUpResponse>();
|
|
|
|
// dbg!(&response);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sign_up_with_invalid_email() {
|
|
|
|
for email in invalid_email_test_case() {
|
|
|
|
let request = SignUpRequest {
|
|
|
|
email: email.to_string(),
|
|
|
|
name: valid_name(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-07-11 13:54:55 +00:00
|
|
|
assert_eq!(
|
2021-07-14 00:23:35 +00:00
|
|
|
UserEventTester::new(SignUp)
|
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_up_with_invalid_password() {
|
|
|
|
for password in invalid_password_test_case() {
|
|
|
|
let request = SignUpRequest {
|
|
|
|
email: valid_email(),
|
|
|
|
name: valid_name(),
|
|
|
|
password,
|
|
|
|
};
|
|
|
|
|
2021-07-11 13:54:55 +00:00
|
|
|
assert_eq!(
|
2021-07-14 00:23:35 +00:00
|
|
|
UserEventTester::new(SignUp)
|
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
|
|
|
}
|
|
|
|
}
|