🐛 Fix undo on page relocate/sorting.

This commit is contained in:
Andrey Antukh 2021-11-24 12:37:55 +01:00 committed by Andrés Moya
parent c4947d3737
commit e7b4010eba
9 changed files with 89 additions and 33 deletions

View file

@ -0,0 +1,50 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) UXBOX Labs SL
(ns app.common.pages-helpers-test
(:require
[clojure.test :as t]
[clojure.pprint :refer [pprint]]
[app.common.pages.helpers :as cph]))
(t/deftest insert-at-index
;; insert different object
(t/is (= (cph/insert-at-index [:a :b] 1 [:c :d])
[:a :c :d :b]))
;; insert on the start
(t/is (= (cph/insert-at-index [:a :b] 0 [:c])
[:c :a :b]))
;; insert on the end 1
(t/is (= (cph/insert-at-index [:a :b] 2 [:c])
[:a :b :c]))
;; insert on the end with not existing index
(t/is (= (cph/insert-at-index [:a :b] 10 [:c])
[:a :b :c]))
;; insert existing in a contiguos index
(t/is (= (cph/insert-at-index [:a :b] 1 [:a])
[:b :a]))
;; insert existing in the same index
(t/is (= (cph/insert-at-index [:a :b] 0 [:a])
[:a :b]))
;; insert existing in other index case 1
(t/is (= (cph/insert-at-index [:a :b :c] 2 [:a])
[:b :c :a]))
;; insert existing in other index case 2
(t/is (= (cph/insert-at-index [:a :b :c :d] 0 [:d])
[:d :a :b :c]))
;; insert existing in other index case 3
(t/is (= (cph/insert-at-index [:a :b :c :d] 1 [:a])
[:b :a :c :d]))
)

View file

@ -574,7 +574,7 @@
;; After
(t/is (= [shape-4-id shape-3-id group-1-id]
(t/is (= [shape-4-id group-1-id shape-3-id]
(get-in res [:pages-index page-id :objects cp/root :shapes])))
;; (pprint (get-in data [:pages-index page-id :objects cp/root]))