Browse Source

fix tests

Tienson Qin 3 years ago
parent
commit
544f0aed81

+ 3 - 4
src/main/frontend/format/block.cljs

@@ -496,10 +496,9 @@
                   blocks)
                  blocks)
         blocks (map (fn [block]
-                      (let [delete-keys (if with-body?
-                                          [:block/anchor]
-                                          [:block/anchor :block/body])]
-                        (apply dissoc block delete-keys))) blocks)]
+                      (if with-body?
+                        block
+                        (dissoc block :block/body))) blocks)]
     (with-path-refs blocks)))
 
 (defn ^:large-vars/cleanup-todo extract-blocks

+ 1 - 1
src/main/frontend/handler/extract.cljs

@@ -130,7 +130,7 @@
           pages (remove nil? pages)
           pages (map (fn [page] (assoc page :block/uuid (db/new-block-id))) pages)
           blocks (->> (remove nil? blocks)
-                      (map (fn [b] (dissoc b :block/title :block/body :block/level :block/children :block/meta))))]
+                      (map (fn [b] (dissoc b :block/title :block/body :block/level :block/children :block/meta :block/anchor))))]
       [pages blocks])
     (catch js/Error e
       (log/error :exception e))))

+ 5 - 14
src/test/frontend/handler/extract_test.cljs

@@ -13,7 +13,7 @@
       (do
         (util/pprint (map (fn [x] (select-keys x [:block/uuid :block/level :block/content :block/left])) result))
         (throw (js/Error. ":block/parent && :block/left conflicts")))
-      (mapv (juxt :block/level :block/content) result))))
+      (mapv :block/content result))))
 
 (defn- async-test
   [x y]
@@ -30,7 +30,7 @@
    "- a
   - b
     - c"
-   [[1 "a"] [2 "b"] [3 "c"]])
+   ["a" "b" "c"])
 
   (async-test
    "## hello
@@ -39,7 +39,7 @@
         - nice
       - bingo
       - world"
-   [[1 "## hello"] [2 "world"] [3 "nice"] [4 "nice"] [3 "bingo"] [3 "world"]])
+   ["## hello" "world" "nice" "nice" "bingo" "world"])
 
   (async-test
    "# a
@@ -53,16 +53,7 @@
   - i
 - j"
 
-   [[1 "# a"]
-    [1 "## b"]
-    [1 "### c"]
-    [1 "#### d"]
-    [1 "### e"]
-    [1 "f"]
-    [2 "g"]
-    [3 "h"]
-    [2 "i"]
-    [1 "j"]]))
+   ["# a" "## b" "### c" "#### d" "### e" "f" "g" "h" "i" "j"]))
 
 (deftest test-regression-1902
   []
@@ -71,6 +62,6 @@
     - line2
       - line3
      - line4"
-   [[1 "line1"] [2 "line2"] [3 "line3"] [3 "line4"]]))
+   ["line1" "line2" "line3" "line4"]))
 
 #_(cljs.test/run-tests)

+ 1 - 5
src/test/frontend/modules/outliner/ds_test.cljs

@@ -12,7 +12,6 @@
                     nil
                     (let [datom [{:block/uuid #uuid"606c1962-ad7f-424e-b120-0dc7fcb25415",
                                   :block/refs (),
-                                  :block/anchor "level_2123123",
                                   :block/repo "logseq_local_test_navtive_fs",
                                   :block/meta {:timestamps [], :properties [], :start-pos 0, :end-pos 15},
                                   :block/format :markdown,
@@ -24,14 +23,11 @@
                                   :block/path-refs (),}]]
                       (ds/add-txs txs-state datom)))
         rt [[72 :block/uuid #uuid "606c1962-ad7f-424e-b120-0dc7fcb25415" 536870913 true]
-            [72 :block/anchor "level_2123123" 536870913 true]
             [72 :block/repo "logseq_local_test_navtive_fs" 536870913 true]
-            [72 :block/meta {:timestamps [], :properties [], :start-pos 0, :end-pos 15} 536870913 true]
             [72 :block/format :markdown 536870913 true]
-            [72 :block/level 1 536870913 true]
             [72 :block/refs-with-children () 536870913 true]
             [72 :block/content "level test" 536870913 true]]]
     (is (= rt (mapv vec (:tx-data db-report))))))
 
 (comment
-  (run-test test-with-db-macro))
+  (test/run-tests))