block_test.rs 1007 B

12345678910111213141516171819202122232425262728
  1. use flowy_test::document::text_block_event::TextBlockEventTest;
  2. use flowy_test::document::utils::gen_text_block_data;
  3. #[tokio::test]
  4. async fn insert_text_block_test() {
  5. let test = TextBlockEventTest::new().await;
  6. let text = "Hello World".to_string();
  7. let block_id = test.insert_index(text.clone(), 1, None).await;
  8. let block = test.get(&block_id).await;
  9. assert!(block.is_some());
  10. let block = block.unwrap();
  11. let data = gen_text_block_data(text);
  12. assert_eq!(block.data, data);
  13. }
  14. #[tokio::test]
  15. async fn update_text_block_test() {
  16. let test = TextBlockEventTest::new().await;
  17. let insert_text = "Hello World".to_string();
  18. let block_id = test.insert_index(insert_text.clone(), 1, None).await;
  19. let update_text = "Hello World 2".to_string();
  20. test.update(&block_id, update_text.clone()).await;
  21. let block = test.get(&block_id).await;
  22. assert!(block.is_some());
  23. let block = block.unwrap();
  24. let update_data = gen_text_block_data(update_text);
  25. assert_eq!(block.data, update_data);
  26. }