document_compose_test.rs 1.6 KB

123456789101112131415161718192021222324
  1. use crate::new_document::script::DocumentEditorTest;
  2. use crate::new_document::script::EditScript::*;
  3. #[tokio::test]
  4. async fn document_insert_h1_style_test() {
  5. let scripts = vec![
  6. ComposeTransactionStr {
  7. transaction: r#"{"operations":[{"op":"update_text","path":[0,0],"delta":[{"insert":"/"}],"inverted":[{"delete":1}]}],"after_selection":{"start":{"path":[0,0],"offset":1},"end":{"path":[0,0],"offset":1}},"before_selection":{"start":{"path":[0,0],"offset":0},"end":{"path":[0,0],"offset":0}}}"#,
  8. },
  9. AssertContent {
  10. expected: r#"{"document":{"type":"editor","children":[{"type":"text","delta":[{"insert":"/"}]}]}}"#,
  11. },
  12. ComposeTransactionStr {
  13. transaction: r#"{"operations":[{"op":"update_text","path":[0,0],"delta":[{"delete":1}],"inverted":[{"insert":"/"}]}],"after_selection":{"start":{"path":[0,0],"offset":0},"end":{"path":[0,0],"offset":0}},"before_selection":{"start":{"path":[0,0],"offset":1},"end":{"path":[0,0],"offset":1}}}"#,
  14. },
  15. ComposeTransactionStr {
  16. transaction: r#"{"operations":[{"op":"update","path":[0,0],"attributes":{"subtype":"heading","heading":"h1"},"oldAttributes":{"subtype":null,"heading":null}}],"after_selection":{"start":{"path":[0,0],"offset":0},"end":{"path":[0,0],"offset":0}},"before_selection":{"start":{"path":[0,0],"offset":0},"end":{"path":[0,0],"offset":0}}}"#,
  17. },
  18. AssertContent {
  19. expected: r#"{"document":{"type":"editor","children":[{"type":"text","attributes":{"subtype":"heading","heading":"h1"}}]}}"#,
  20. },
  21. ];
  22. DocumentEditorTest::new().await.run_scripts(scripts).await;
  23. }