|
@@ -1,8 +1,7 @@
|
|
|
(ns logseq.graph-parser.text-test
|
|
|
(:require [cljs.test :refer [are deftest testing]]
|
|
|
[logseq.graph-parser.text :as text]
|
|
|
- [logseq.graph-parser.mldoc :as gp-mldoc]
|
|
|
- [logseq.graph-parser.util :as gp-util]))
|
|
|
+ [logseq.graph-parser.mldoc :as gp-mldoc]))
|
|
|
|
|
|
(deftest test-get-page-name
|
|
|
[]
|
|
@@ -62,27 +61,41 @@
|
|
|
"*********************foobar" "foobar")))
|
|
|
|
|
|
(defn- parse-property
|
|
|
- [k v]
|
|
|
- (let [references (-> (gp-mldoc/get-references v (gp-mldoc/default-config :markdown))
|
|
|
- (gp-util/json->clj))]
|
|
|
- (text/parse-property k v references {})))
|
|
|
+ [k v user-config]
|
|
|
+ (let [references (gp-mldoc/get-references v (gp-mldoc/default-config :markdown))]
|
|
|
+ (text/parse-property k v references user-config)))
|
|
|
|
|
|
(deftest test-parse-property
|
|
|
- (testing "parse-property"
|
|
|
- (are [k v y] (= (parse-property k v) y)
|
|
|
- :tags "foo" ["foo"]
|
|
|
- :tags "[[foo]], [[bar]]" #{"foo" "bar"}
|
|
|
- :tags "[[foo]],[[bar]]" #{"foo" "bar"}
|
|
|
- :tags "[[foo]]" #{"foo"}
|
|
|
- :tags "[[foo]] [[bar]]" #{"foo" "bar"}
|
|
|
- :tags "[[foo]], [[bar]]" #{"foo" "bar"}
|
|
|
- :tags "[[foo]], [[bar]], #baz" #{"foo" "bar" "baz"}
|
|
|
- :tags "#baz, [[foo]], [[bar]]" #{"foo" "bar" "baz"}
|
|
|
- :tags "[[foo [[bar]]]]" #{"foo [[bar]]"}
|
|
|
- :tags "[[foo [[bar]]]], [[baz]]" #{"baz" "foo [[bar]]"}))
|
|
|
+ (testing "for default comma separated properties"
|
|
|
+ (are [k v y] (= (parse-property k v {}) y)
|
|
|
+ :tags "foo" #{"foo"}
|
|
|
+ :tags "comma, separated" #{"comma" "separated"}
|
|
|
+ :alias "one, two, one" #{"one" "two"}))
|
|
|
+
|
|
|
+ (testing "for user comma separated properties"
|
|
|
+ (are [k v y] (= (parse-property k v {:property/separated-by-commas #{:comma-prop}}) y)
|
|
|
+ :comma-prop "foo" #{"foo"}
|
|
|
+ :comma-prop "comma, separated" #{"comma" "separated"}
|
|
|
+ :comma-prop "one, two, one" #{"one" "two"}))
|
|
|
+
|
|
|
+ (testing "for normal properties"
|
|
|
+ (are [k v y] (= (parse-property k v {}) y)
|
|
|
+ :normal "[[foo]] [[bar]]" #{"foo" "bar"}
|
|
|
+ :normal "[[foo]], [[bar]]" #{"foo" "bar"}
|
|
|
+ :normal "[[foo]]" #{"foo"}
|
|
|
+ :normal "[[foo]], [[bar]], #baz" #{"foo" "bar" "baz"}
|
|
|
+ :normal "[[foo [[bar]]]]" #{"foo [[bar]]"}
|
|
|
+ :normal "[[foo [[bar]]]], [[baz]]" #{"baz" "foo [[bar]]"}
|
|
|
+ :title "comma, is ok" "comma, is ok"))
|
|
|
+
|
|
|
+ (testing "for tags in properties with punctuation"
|
|
|
+ (are [k v y] (= (parse-property k v {}) y)
|
|
|
+ :prop "#foo, #bar. #baz!" #{"foo" "bar" "baz"}
|
|
|
+ :prop "#foo: '#bar'" #{"foo" "bar"}))
|
|
|
+
|
|
|
(testing "parse-property with quoted strings"
|
|
|
- (are [k v y] (= (parse-property k v) y)
|
|
|
- :tags "\"foo, bar\"" "\"foo, bar\""
|
|
|
- :tags "\"[[foo]], [[bar]]\"" "\"[[foo]], [[bar]]\"")))
|
|
|
+ (are [k v y] (= (parse-property k v {}) y)
|
|
|
+ :tags "\"foo, bar\"" "\"foo, bar\""
|
|
|
+ :tags "\"[[foo]], [[bar]]\"" "\"[[foo]], [[bar]]\"")))
|
|
|
|
|
|
#_(cljs.test/test-ns 'logseq.graph-parser.text-test)
|