Ver Fonte

Add test cases for moving blocks

Tienson Qin há 1 ano atrás
pai
commit
0c988f12ce
1 ficheiros alterados com 28 adições e 0 exclusões
  1. 28 0
      src/test/frontend/modules/outliner/core_test.cljs

+ 28 - 0
src/test/frontend/modules/outliner/core_test.cljs

@@ -180,6 +180,34 @@
       (is (= [6 9] (get-children 2)))
       (is (= [3 13 14 15] (get-children 12))))))
 
+(deftest test-move-child-as-first-sibling
+  (testing "Move 3 as sibling of 2."
+    (transact-tree! [[22 [[2 [[3]
+                              [4]]]
+                          [5]]]])
+    (outliner-tx/transact!
+     (transact-opts)
+     (outliner-core/move-blocks! test-db
+                                 (db/get-db test-db false)
+                                 [(get-block 3)] (get-block 2) true))
+    (is (= [4] (get-children 2)))
+    (is (= [2 3 5] (get-children 22)))))
+
+(deftest test-move-non-consecutive-blocks
+  (testing "Move 3 as sibling of 2."
+    (transact-tree! [[22 [[2 [[3]
+                              [4]]]
+                          [5]
+                          [6]
+                          [7]]]])
+    (outliner-tx/transact!
+     (transact-opts)
+     (outliner-core/move-blocks! test-db
+                                 (db/get-db test-db false)
+                                 [(get-block 3) (get-block 6)] (get-block 2) true))
+    (is (= [4] (get-children 2)))
+    (is (= [2 3 6 5 7] (get-children 22)))))
+
 (deftest test-indent-blocks
   (testing "
   [1 [[2 [[3