Browse Source

fix: wrong title in page's properties

Tienson Qin 4 years ago
parent
commit
691c3972a2
2 changed files with 16 additions and 1 deletions
  1. 1 1
      src/main/frontend/util/property.cljs
  2. 15 0
      src/test/frontend/util/property_test.cljs

+ 1 - 1
src/main/frontend/util/property.cljs

@@ -92,7 +92,7 @@
     (let [org? (= format :org)
           kv-format (if org? ":%s: %s" "%s:: %s")
           full-format (if org? ":PROPERTIES:\n%s\n:END:\n" "%s\n")
-          properties-content (->> (map (fn [[k v]] (util/format kv-format k v)) properties)
+          properties-content (->> (map (fn [[k v]] (util/format kv-format (name k) v)) properties)
                                   (string/join "\n"))]
       (util/format full-format properties-content))))
 

+ 15 - 0
src/test/frontend/util/property_test.cljs

@@ -90,5 +90,20 @@
     "hello\n:PROPERTIES:\n:foo: bar\n:nice\n:END:\nnice"
     "hello\nfoo:: bar\n:nice\nnice"))
 
+(deftest test-build-properties-str
+  (are [x y] (= (property/build-properties-str :mardown x) y)
+    {:title "a"}
+    "title:: a\n"
+    {:title "a/b/c"}
+    "title:: a/b/c\n"
+    {:title "a/b/c" :tags "d,e"}
+    "title:: a/b/c\ntags:: d,e\n")
+  (are [x y] (= (property/build-properties-str :org x) y)
+    {:title "a"}
+    ":PROPERTIES:\n:title: a\n:END:\n"
+    {:title "a/b/c"}
+    ":PROPERTIES:\n:title: a/b/c\n:END:\n"
+    {:title "a/b/c" :tags "d,e"}
+    ":PROPERTIES:\n:title: a/b/c\n:tags: d,e\n:END:\n"))
 
 #_(cljs.test/run-tests)