2023-01-30 11:11:19 +08:00
|
|
|
use flowy_client_sync::client_folder::{FolderNodePad, WorkspaceNode};
|
2022-12-02 22:31:03 +08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn client_folder_create_default_folder_test() {
|
2023-02-13 09:29:49 +08:00
|
|
|
let folder_pad = FolderNodePad::new();
|
|
|
|
let json = folder_pad.to_json(false).unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
json,
|
|
|
|
r#"{"type":"folder","children":[{"type":"workspaces"},{"type":"trash"}]}"#
|
|
|
|
);
|
2022-12-02 22:31:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn client_folder_create_default_folder_with_workspace_test() {
|
2023-02-13 09:29:49 +08:00
|
|
|
let mut folder_pad = FolderNodePad::new();
|
|
|
|
let workspace = WorkspaceNode::new(
|
|
|
|
folder_pad.tree.clone(),
|
|
|
|
"1".to_string(),
|
|
|
|
"workspace name".to_string(),
|
|
|
|
);
|
|
|
|
folder_pad.workspaces.add_workspace(workspace).unwrap();
|
|
|
|
let json = folder_pad.to_json(false).unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
json,
|
|
|
|
r#"{"type":"folder","children":[{"type":"workspaces","children":[{"type":"workspace","attributes":{"id":"1","name":"workspace name"}}]},{"type":"trash"}]}"#
|
|
|
|
);
|
2022-12-02 22:31:03 +08:00
|
|
|
|
2023-02-13 09:29:49 +08:00
|
|
|
assert_eq!(
|
|
|
|
folder_pad.get_workspace("1").unwrap().get_name().unwrap(),
|
|
|
|
"workspace name"
|
|
|
|
);
|
2022-12-02 22:31:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn client_folder_delete_workspace_test() {
|
2023-02-13 09:29:49 +08:00
|
|
|
let mut folder_pad = FolderNodePad::new();
|
|
|
|
let workspace = WorkspaceNode::new(
|
|
|
|
folder_pad.tree.clone(),
|
|
|
|
"1".to_string(),
|
|
|
|
"workspace name".to_string(),
|
|
|
|
);
|
|
|
|
folder_pad.workspaces.add_workspace(workspace).unwrap();
|
|
|
|
folder_pad.workspaces.remove_workspace("1");
|
|
|
|
let json = folder_pad.to_json(false).unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
json,
|
|
|
|
r#"{"type":"folder","children":[{"type":"workspaces"},{"type":"trash"}]}"#
|
|
|
|
);
|
2022-12-02 22:31:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn client_folder_update_workspace_name_test() {
|
2023-02-13 09:29:49 +08:00
|
|
|
let mut folder_pad = FolderNodePad::new();
|
|
|
|
let workspace = WorkspaceNode::new(
|
|
|
|
folder_pad.tree.clone(),
|
|
|
|
"1".to_string(),
|
|
|
|
"workspace name".to_string(),
|
|
|
|
);
|
|
|
|
folder_pad.workspaces.add_workspace(workspace).unwrap();
|
|
|
|
folder_pad
|
|
|
|
.workspaces
|
|
|
|
.get_mut_workspace("1")
|
|
|
|
.unwrap()
|
|
|
|
.set_name("my first workspace".to_string());
|
2022-12-04 15:23:24 +08:00
|
|
|
|
2023-02-13 09:29:49 +08:00
|
|
|
assert_eq!(
|
|
|
|
folder_pad
|
|
|
|
.workspaces
|
|
|
|
.get_workspace("1")
|
|
|
|
.unwrap()
|
|
|
|
.get_name()
|
|
|
|
.unwrap(),
|
|
|
|
"my first workspace"
|
|
|
|
);
|
2022-12-02 22:31:03 +08:00
|
|
|
}
|