|
@@ -5,7 +5,7 @@
|
|
(deftest extract-nearest-link-from-text-test
|
|
(deftest extract-nearest-link-from-text-test
|
|
(testing "Page, block and tag links"
|
|
(testing "Page, block and tag links"
|
|
(is (= "page1"
|
|
(is (= "page1"
|
|
- (editor/extract-nearest-link-from-text "[[page1]] [[page2]]" 0))
|
|
|
|
|
|
+ (editor/extract-nearest-link-from-text "[[page1]] [[page2]]" 0))
|
|
"Finds first page link correctly based on cursor position")
|
|
"Finds first page link correctly based on cursor position")
|
|
|
|
|
|
(is (= "page2"
|
|
(is (= "page2"
|
|
@@ -23,13 +23,13 @@
|
|
|
|
|
|
(testing "Url links"
|
|
(testing "Url links"
|
|
(is (= "https://github.com/logseq/logseq"
|
|
(is (= "https://github.com/logseq/logseq"
|
|
- (editor/extract-nearest-link-from-text
|
|
|
|
- "https://github.com/logseq/logseq is #awesome :)" 0 editor/url-regex))
|
|
|
|
|
|
+ (editor/extract-nearest-link-from-text
|
|
|
|
+ "https://github.com/logseq/logseq is #awesome :)" 0 editor/url-regex))
|
|
"Finds url correctly")
|
|
"Finds url correctly")
|
|
|
|
|
|
(is (not= "https://github.com/logseq/logseq"
|
|
(is (not= "https://github.com/logseq/logseq"
|
|
- (editor/extract-nearest-link-from-text
|
|
|
|
- "https://github.com/logseq/logseq is #awesome :)" 0))
|
|
|
|
|
|
+ (editor/extract-nearest-link-from-text
|
|
|
|
+ "https://github.com/logseq/logseq is #awesome :)" 0))
|
|
"Doesn't find url if regex not passed")
|
|
"Doesn't find url if regex not passed")
|
|
|
|
|
|
(is (= "https://github.com/logseq/logseq"
|
|
(is (= "https://github.com/logseq/logseq"
|
|
@@ -43,22 +43,22 @@
|
|
"Finds url in org link correctly"))
|
|
"Finds url in org link correctly"))
|
|
|
|
|
|
(defn- set-marker
|
|
(defn- set-marker
|
|
- [marker content format new-marker]
|
|
|
|
|
|
+ [marker content format]
|
|
(let [actual-content (atom nil)]
|
|
(let [actual-content (atom nil)]
|
|
(with-redefs [editor/save-block-if-changed! (fn [_ content]
|
|
(with-redefs [editor/save-block-if-changed! (fn [_ content]
|
|
(reset! actual-content content))]
|
|
(reset! actual-content content))]
|
|
- (editor/set-marker {:block/marker marker :block/content content :block/format format}
|
|
|
|
- new-marker)
|
|
|
|
|
|
+ (editor/set-marker {:block/marker marker :block/content content :block/format format})
|
|
@actual-content)))
|
|
@actual-content)))
|
|
|
|
|
|
(deftest set-marker-org
|
|
(deftest set-marker-org
|
|
- (are [marker content new-marker expect] (= expect (set-marker marker content :org new-marker))
|
|
|
|
- "TODO" "TODO content" "DOING" "DOING content"
|
|
|
|
- "TODO" "## TODO content" "DOING" "## TODO content"
|
|
|
|
- "DONE" "DONE content" "" "content"))
|
|
|
|
|
|
+ (are [marker content expect] (= expect (set-marker marker content :org))
|
|
|
|
+ "TODO" "TODO content" "DOING content"
|
|
|
|
+ "TODO" "** TODO content" "** DOING content"
|
|
|
|
+ "TODO" "## TODO content" "DOING ## TODO content"
|
|
|
|
+ "DONE" "DONE content" "content"))
|
|
|
|
|
|
(deftest set-marker-markdown
|
|
(deftest set-marker-markdown
|
|
- (are [marker content new-marker expect] (= expect (set-marker marker content :markdown new-marker))
|
|
|
|
- "TODO" "TODO content" "DOING" "DOING content"
|
|
|
|
- "TODO" "## TODO content" "DOING" "## DOING content"
|
|
|
|
- "DONE" "DONE content" "" "content"))
|
|
|
|
|
|
+ (are [marker content expect] (= expect (set-marker marker content :markdown))
|
|
|
|
+ "TODO" "TODO content" "DOING content"
|
|
|
|
+ "TODO" "## TODO content" "## DOING content"
|
|
|
|
+ "DONE" "DONE content" "content"))
|