AppFlowy/rust-lib/flowy-workspace/tests/event/helper.rs

74 lines
1.8 KiB
Rust
Raw Normal View History

pub use flowy_test::builder::SingleUserTestBuilder;
2021-07-20 06:03:21 +00:00
use flowy_workspace::{
2021-07-20 07:51:49 +00:00
entities::{app::*, view::*, workspace::*},
event::WorkspaceEvent::*,
2021-07-20 06:03:21 +00:00
};
pub(crate) fn invalid_workspace_name_test_case() -> Vec<String> {
vec!["", "1234".repeat(100).as_str()]
.iter()
.map(|s| s.to_string())
.collect::<Vec<_>>()
}
2021-07-20 06:03:21 +00:00
pub fn create_workspace(name: &str, desc: &str) -> Workspace {
let request = CreateWorkspaceRequest {
name: name.to_owned(),
desc: desc.to_owned(),
};
let workspace = SingleUserTestBuilder::new()
2021-07-20 06:03:21 +00:00
.event(CreateWorkspace)
.request(request)
.sync_send()
.parse::<Workspace>();
workspace
}
pub fn create_app(name: &str, desc: &str, workspace_id: &str) -> App {
let create_app_request = CreateAppRequest {
workspace_id: workspace_id.to_string(),
name: name.to_string(),
desc: desc.to_string(),
color_style: Default::default(),
};
let app = SingleUserTestBuilder::new()
2021-07-20 06:03:21 +00:00
.event(CreateApp)
.request(create_app_request)
.sync_send()
.parse::<App>();
app
}
pub fn get_workspace(request: QueryWorkspaceRequest) -> Workspace {
let workspace = SingleUserTestBuilder::new()
2021-07-20 06:03:21 +00:00
.event(GetWorkspace)
.request(request)
.sync_send()
.parse::<Workspace>();
workspace
}
2021-07-20 07:51:49 +00:00
pub fn get_app(request: QueryAppRequest) -> App {
let app = SingleUserTestBuilder::new()
2021-07-20 07:51:49 +00:00
.event(GetApp)
.request(request)
.sync_send()
.parse::<App>();
app
}
pub fn create_view(request: CreateViewRequest) -> View {
let view = SingleUserTestBuilder::new()
2021-07-20 07:51:49 +00:00
.event(CreateView)
.request(request)
.sync_send()
.parse::<View>();
view
}