2022-06-20 02:24:43 +00:00
|
|
|
use crate::grid::script::EditorScript::*;
|
|
|
|
use crate::grid::script::*;
|
2022-06-26 07:14:24 +00:00
|
|
|
use flowy_grid_data_model::revision::{GridBlockMetaRevision, GridBlockMetaRevisionChangeset};
|
2022-06-20 02:24:43 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn grid_create_block() {
|
2022-06-26 07:14:24 +00:00
|
|
|
let block_meta_rev = GridBlockMetaRevision::new();
|
2022-06-20 02:24:43 +00:00
|
|
|
let scripts = vec![
|
|
|
|
AssertBlockCount(1),
|
2022-06-26 07:14:24 +00:00
|
|
|
CreateBlock { block: block_meta_rev },
|
2022-06-20 02:24:43 +00:00
|
|
|
AssertBlockCount(2),
|
|
|
|
];
|
|
|
|
GridEditorTest::new().await.run_scripts(scripts).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn grid_update_block() {
|
2022-06-26 07:14:24 +00:00
|
|
|
let block_meta_rev = GridBlockMetaRevision::new();
|
|
|
|
let mut cloned_grid_block = block_meta_rev.clone();
|
|
|
|
let changeset = GridBlockMetaRevisionChangeset {
|
|
|
|
block_id: block_meta_rev.block_id.clone(),
|
2022-06-20 02:24:43 +00:00
|
|
|
start_row_index: Some(2),
|
|
|
|
row_count: Some(10),
|
|
|
|
};
|
|
|
|
|
|
|
|
cloned_grid_block.start_row_index = 2;
|
|
|
|
cloned_grid_block.row_count = 10;
|
|
|
|
|
|
|
|
let scripts = vec![
|
|
|
|
AssertBlockCount(1),
|
2022-06-26 07:14:24 +00:00
|
|
|
CreateBlock { block: block_meta_rev },
|
2022-06-20 02:24:43 +00:00
|
|
|
UpdateBlock { changeset },
|
|
|
|
AssertBlockCount(2),
|
|
|
|
AssertBlockEqual {
|
|
|
|
block_index: 1,
|
|
|
|
block: cloned_grid_block,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
GridEditorTest::new().await.run_scripts(scripts).await;
|
|
|
|
}
|