2021-07-19 08:15:20 +00:00
|
|
|
use crate::helper::*;
|
|
|
|
use flowy_user::{errors::*, event::UserEvent::*, prelude::*};
|
|
|
|
use serial_test::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[serial]
|
|
|
|
fn sign_up_success() {
|
|
|
|
let request = SignUpRequest {
|
|
|
|
email: random_valid_email(),
|
|
|
|
name: valid_name(),
|
|
|
|
password: valid_password(),
|
|
|
|
};
|
|
|
|
|
2021-08-30 14:44:17 +00:00
|
|
|
let _response = RandomUserTestBuilder::new()
|
2021-07-19 08:15:20 +00:00
|
|
|
.logout()
|
|
|
|
.event(SignUp)
|
|
|
|
.request(request)
|
|
|
|
.sync_send();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[serial]
|
|
|
|
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(),
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(
|
2021-08-30 14:44:17 +00:00
|
|
|
RandomUserTestBuilder::new()
|
2021-07-19 08:15:20 +00:00
|
|
|
.event(SignUp)
|
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.error()
|
|
|
|
.code,
|
2021-08-30 14:44:17 +00:00
|
|
|
ErrorCode::EmailFormatInvalid
|
2021-07-19 08:15:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
#[serial]
|
|
|
|
fn sign_up_with_invalid_password() {
|
|
|
|
for password in invalid_password_test_case() {
|
|
|
|
let request = SignUpRequest {
|
|
|
|
email: random_valid_email(),
|
|
|
|
name: valid_name(),
|
|
|
|
password,
|
|
|
|
};
|
|
|
|
|
2021-08-30 14:44:17 +00:00
|
|
|
RandomUserTestBuilder::new()
|
2021-08-24 05:10:53 +00:00
|
|
|
.event(SignUp)
|
|
|
|
.request(request)
|
|
|
|
.sync_send()
|
|
|
|
.assert_error();
|
2021-07-19 08:15:20 +00:00
|
|
|
}
|
|
|
|
}
|