|
@@ -7,6 +7,7 @@
|
|
|
[frontend.commands :as commands]
|
|
|
[frontend.util :as util]
|
|
|
[promesa.core :as p]
|
|
|
+ [frontend.extensions.html-parser :as html-parser]
|
|
|
[frontend.handler.paste :as paste-handler]))
|
|
|
|
|
|
(deftest try-parse-as-json-result-parse-test
|
|
@@ -75,7 +76,7 @@
|
|
|
:selection-end 76
|
|
|
:selection "https://logseq.com) is developed with [Clojure](https://clojure.org"} false))
|
|
|
|
|
|
-(deftest-async editor-on-paste-raw-link
|
|
|
+(deftest-async editor-on-paste-raw-with-link
|
|
|
(testing "Raw paste for link should just paste link"
|
|
|
(let [clipboard "https://www.youtube.com/watch?v=xu9p5ynlhZk"
|
|
|
expected-paste "https://www.youtube.com/watch?v=xu9p5ynlhZk"]
|
|
@@ -89,3 +90,23 @@
|
|
|
(p/let [result ((paste-handler/editor-on-paste! nil true))]
|
|
|
(is (= expected-paste result))
|
|
|
(reset))))))
|
|
|
+
|
|
|
+(deftest-async editor-on-paste-normal-with-link
|
|
|
+ (testing "Normal paste for link should paste macro wrapped link"
|
|
|
+ (let [clipboard "https://www.youtube.com/watch?v=xu9p5ynlhZk"
|
|
|
+ expected-paste "{{video https://www.youtube.com/watch?v=xu9p5ynlhZk}}"]
|
|
|
+ (test-helper/with-reset
|
|
|
+ reset
|
|
|
+ ;; These redefs are like above
|
|
|
+ [utils/getClipText (fn [cb] (cb clipboard))
|
|
|
+ state/get-input (constantly #js {:value "block"})
|
|
|
+ commands/delete-selection! (constantly nil)
|
|
|
+ commands/simple-insert! (fn [_input text] (p/resolved text))
|
|
|
+ util/get-selected-text (constantly nil)
|
|
|
+ ;; Specific redefs to normal paste
|
|
|
+ util/stop (constantly nil)
|
|
|
+ html-parser/convert (constantly nil)]
|
|
|
+ (p/let [result ((paste-handler/editor-on-paste! nil)
|
|
|
+ #js {:clipboardData #js {:getData (constantly clipboard)}})]
|
|
|
+ (is (= expected-paste result))
|
|
|
+ (reset))))))
|