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

58 lines
1.6 KiB
Rust
Raw Normal View History

2021-07-20 07:51:49 +00:00
use crate::helper::*;
2021-07-25 00:13:59 +00:00
use flowy_workspace::entities::{app::QueryAppRequest, view::*};
#[test]
fn app_create_success() {
2021-07-20 07:51:49 +00:00
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
dbg!(&app);
}
2021-07-20 06:03:21 +00:00
2021-07-20 07:51:49 +00:00
#[test]
fn app_create_and_then_get_success() {
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
let request = QueryAppRequest {
app_id: app.id.clone(),
read_views: false,
};
let app_from_db = get_app(request);
assert_eq!(app_from_db, app);
2021-07-20 06:03:21 +00:00
}
#[test]
2021-07-20 07:51:49 +00:00
fn app_create_with_view_and_then_get_success() {
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
let request_a = CreateViewRequest {
2021-07-28 05:41:39 +00:00
belong_to_id: app.id.clone(),
2021-07-20 07:51:49 +00:00
name: "View A".to_string(),
desc: "".to_string(),
thumbnail: None,
2021-07-22 09:39:44 +00:00
view_type: ViewType::Doc,
};
2021-07-20 07:51:49 +00:00
let request_b = CreateViewRequest {
2021-07-28 05:41:39 +00:00
belong_to_id: app.id.clone(),
2021-07-20 07:51:49 +00:00
name: "View B".to_string(),
desc: "".to_string(),
thumbnail: None,
2021-07-22 09:39:44 +00:00
view_type: ViewType::Doc,
2021-07-20 07:51:49 +00:00
};
let view_a = create_view(request_a);
let view_b = create_view(request_b);
let query = QueryAppRequest {
app_id: app.id.clone(),
read_views: true,
};
let view_from_db = get_app(query);
2021-07-20 07:51:49 +00:00
assert_eq!(view_from_db.views[0], view_a);
assert_eq!(view_from_db.views[1], view_b);
}
// TODO 1) test update app 2) delete app