|
@@ -70,13 +70,12 @@
|
|
|
(testing "Sort order and persistence of 10 properties"
|
|
(testing "Sort order and persistence of 10 properties"
|
|
|
(test-property-order 10)))
|
|
(test-property-order 10)))
|
|
|
|
|
|
|
|
-(defn- quoted-property-values-test
|
|
|
|
|
- [user-config]
|
|
|
|
|
|
|
+(deftest quoted-property-values
|
|
|
(let [conn (ldb/start-conn)
|
|
(let [conn (ldb/start-conn)
|
|
|
_ (graph-parser/parse-file conn
|
|
_ (graph-parser/parse-file conn
|
|
|
"foo.md"
|
|
"foo.md"
|
|
|
"- desc:: \"#foo is not a ref\""
|
|
"- desc:: \"#foo is not a ref\""
|
|
|
- {:extract-options {:user-config user-config}})
|
|
|
|
|
|
|
+ {:extract-options {:user-config {}}})
|
|
|
block (->> (d/q '[:find (pull ?b [* {:block/refs [*]}])
|
|
block (->> (d/q '[:find (pull ?b [* {:block/refs [*]}])
|
|
|
:in $
|
|
:in $
|
|
|
:where [?b :block/properties]]
|
|
:where [?b :block/properties]]
|
|
@@ -90,45 +89,55 @@
|
|
|
(map :block/original-name (:block/refs block)))
|
|
(map :block/original-name (:block/refs block)))
|
|
|
"No refs from property value")))
|
|
"No refs from property value")))
|
|
|
|
|
|
|
|
-(deftest quoted-property-values
|
|
|
|
|
- (testing "With default config"
|
|
|
|
|
- (quoted-property-values-test {})))
|
|
|
|
|
-
|
|
|
|
|
-(deftest page-properties-persistence
|
|
|
|
|
- (testing "Non-string property values"
|
|
|
|
|
- (let [conn (ldb/start-conn)]
|
|
|
|
|
- (graph-parser/parse-file conn
|
|
|
|
|
- "lythe-of-heaven.md"
|
|
|
|
|
- "rating:: 8\nrecommend:: true\narchive:: false"
|
|
|
|
|
- {})
|
|
|
|
|
- (is (= {:rating 8 :recommend true :archive false}
|
|
|
|
|
- (->> (d/q '[:find (pull ?b [*])
|
|
|
|
|
- :in $
|
|
|
|
|
- :where [?b :block/properties]]
|
|
|
|
|
- @conn)
|
|
|
|
|
- (map (comp :block/properties first))
|
|
|
|
|
- first)))))
|
|
|
|
|
|
|
+(deftest non-string-property-values
|
|
|
|
|
+ (let [conn (ldb/start-conn)]
|
|
|
|
|
+ (graph-parser/parse-file conn
|
|
|
|
|
+ "lythe-of-heaven.md"
|
|
|
|
|
+ "rating:: 8\nrecommend:: true\narchive:: false"
|
|
|
|
|
+ {})
|
|
|
|
|
+ (is (= {:rating 8 :recommend true :archive false}
|
|
|
|
|
+ (->> (d/q '[:find (pull ?b [*])
|
|
|
|
|
+ :in $
|
|
|
|
|
+ :where [?b :block/properties]]
|
|
|
|
|
+ @conn)
|
|
|
|
|
+ (map (comp :block/properties first))
|
|
|
|
|
+ first)))))
|
|
|
|
|
|
|
|
- (testing "Linkable built-in properties"
|
|
|
|
|
- (let [conn (ldb/start-conn)
|
|
|
|
|
- _ (graph-parser/parse-file conn
|
|
|
|
|
- "lol.md"
|
|
|
|
|
- "alias:: 233\ntags:: fun, facts"
|
|
|
|
|
- {})
|
|
|
|
|
- block (->> (d/q '[:find (pull ?b [:block/properties {:block/alias [:block/name]} {:block/tags [:block/name]}])
|
|
|
|
|
- :in $
|
|
|
|
|
- :where [?b :block/name "lol"]]
|
|
|
|
|
- @conn)
|
|
|
|
|
- (map first)
|
|
|
|
|
- first)]
|
|
|
|
|
-
|
|
|
|
|
- (is (= {:block/alias [{:block/name "233"}]
|
|
|
|
|
- :block/tags [{:block/name "fun"} {:block/name "facts"}]
|
|
|
|
|
- :block/properties {:alias #{"233"} :tags #{"fun" "facts"}}}
|
|
|
|
|
- block))
|
|
|
|
|
-
|
|
|
|
|
- (is (every? set? (vals (:block/properties block)))
|
|
|
|
|
- "Linked built-in property values as sets provides for easier transforms"))))
|
|
|
|
|
|
|
+(deftest linkable-built-in-properties
|
|
|
|
|
+ (let [conn (ldb/start-conn)
|
|
|
|
|
+ _ (graph-parser/parse-file conn
|
|
|
|
|
+ "lol.md"
|
|
|
|
|
+ (str "alias:: 233\ntags:: fun, facts"
|
|
|
|
|
+ "\n- "
|
|
|
|
|
+ "alias:: 666\ntags:: block, facts")
|
|
|
|
|
+ {})
|
|
|
|
|
+ page-block (->> (d/q '[:find (pull ?b [:block/properties {:block/alias [:block/name]} {:block/tags [:block/name]}])
|
|
|
|
|
+ :in $
|
|
|
|
|
+ :where [?b :block/name "lol"]]
|
|
|
|
|
+ @conn)
|
|
|
|
|
+ (map first)
|
|
|
|
|
+ first)
|
|
|
|
|
+ block (->> (d/q '[:find (pull ?b [:block/properties])
|
|
|
|
|
+ :in $
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?b :block/properties]
|
|
|
|
|
+ [(missing? $ ?b :block/pre-block?)]
|
|
|
|
|
+ [(missing? $ ?b :block/name)]]
|
|
|
|
|
+ @conn)
|
|
|
|
|
+ (map first)
|
|
|
|
|
+ first)]
|
|
|
|
|
+
|
|
|
|
|
+ (is (= {:block/alias [{:block/name "233"}]
|
|
|
|
|
+ :block/tags [{:block/name "fun"} {:block/name "facts"}]
|
|
|
|
|
+ :block/properties {:alias #{"233"} :tags #{"fun" "facts"}}}
|
|
|
|
|
+ page-block)
|
|
|
|
|
+ "page properties, alias and tags are correct")
|
|
|
|
|
+ (is (every? set? (vals (:block/properties page-block)))
|
|
|
|
|
+ "Linked built-in property values as sets provides for easier transforms")
|
|
|
|
|
+
|
|
|
|
|
+ (is (= {:block/properties {:alias #{"666"} :tags #{"block" "facts"}}}
|
|
|
|
|
+ block)
|
|
|
|
|
+ "block properties are correct")))
|
|
|
|
|
|
|
|
(defn- property-relationships-test
|
|
(defn- property-relationships-test
|
|
|
"Runs tests on page properties and block properties. file-properties is what is
|
|
"Runs tests on page properties and block properties. file-properties is what is
|