Add a test for copied blocks

Also removed a prn
This commit is contained in:
Gabriel Horner
2023-03-28 16:51:42 -04:00
committed by Andelf
parent 7318f3ca91
commit 2a78e72f46
2 changed files with 33 additions and 12 deletions

View File

@@ -121,6 +121,24 @@
(is (= expected-paste result))
(reset))))))
(deftest-async editor-on-paste-with-copied-blocks
(let [actual-blocks (atom nil)
;; Simplified version of block attributes that are copied
expected-blocks [{:block/content "Test node"}
{:block/content "Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"}]
clipboard "- Test node\n\t- Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"]
(test-helper/with-reset
reset
[state/get-input (constantly #js {:value "block"})
;; paste-copied-blocks-or-text mocks below
util/stop (constantly nil)
paste-handler/get-copied-blocks (constantly (p/resolved expected-blocks))
editor-handler/paste-blocks (fn [blocks _] (reset! actual-blocks blocks))]
(p/let [_ ((paste-handler/editor-on-paste! nil)
#js {:clipboardData #js {:getData (constantly clipboard)}})]
(is (= expected-blocks @actual-blocks))
(reset)))))
(deftest-async editor-on-paste-with-selection-in-property
(let [clipboard "after"
expected-paste "after"