mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 16:41:37 +02:00
Minor cosmetic changes on tests.
This commit is contained in:
parent
5693ec0142
commit
cc0b61f122
1 changed files with 50 additions and 45 deletions
|
@ -125,6 +125,8 @@
|
||||||
3 {:id 3 :page 1}}}
|
3 {:id 3 :page 1}}}
|
||||||
expected (assoc-in initial [:pages 1 :shapes] [1 3 2])
|
expected (assoc-in initial [:pages 1 :shapes] [1 3 2])
|
||||||
result (impl/drop-shape initial 3 1 :after)]
|
result (impl/drop-shape initial 3 1 :after)]
|
||||||
|
;; (pprint expected)
|
||||||
|
;; (pprint result)
|
||||||
(t/is (= result expected))
|
(t/is (= result expected))
|
||||||
(t/is (vector? (get-in result [:pages 1 :shapes])))))
|
(t/is (vector? (get-in result [:pages 1 :shapes])))))
|
||||||
|
|
||||||
|
@ -286,9 +288,11 @@
|
||||||
4 {:id 4 :page 1}}}
|
4 {:id 4 :page 1}}}
|
||||||
|
|
||||||
shape (get-in initial [:shapes 4])
|
shape (get-in initial [:shapes 4])
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1 :shapes [1 3]}}
|
||||||
(assoc-in [:pages 1 :shapes] [1 3])
|
:shapes {1 {:id 1 :page 1 :type :group :items [2]}
|
||||||
(update-in [:shapes] dissoc 4))
|
2 {:id 2 :page 1 :group 1}
|
||||||
|
3 {:id 3 :page 1}}}
|
||||||
|
|
||||||
result (impl/dissoc-shape initial shape)]
|
result (impl/dissoc-shape initial shape)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
|
@ -304,39 +308,38 @@
|
||||||
3 {:id 3 :page 1}
|
3 {:id 3 :page 1}
|
||||||
4 {:id 4 :page 1}}}
|
4 {:id 4 :page 1}}}
|
||||||
shape (get-in initial [:shapes 2])
|
shape (get-in initial [:shapes 2])
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1 :shapes [3 4]}}
|
||||||
(assoc-in [:pages 1 :shapes] [3 4])
|
:shapes {3 {:id 3 :page 1}
|
||||||
(update-in [:shapes] dissoc 2)
|
4 {:id 4 :page 1}}}
|
||||||
(update-in [:shapes] dissoc 1))
|
|
||||||
result (impl/dissoc-shape initial shape)]
|
result (impl/dissoc-shape initial shape)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
(t/is (= result expected))))
|
(t/is (= result expected))))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;; Group Shapes
|
;; Group Shapes
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; group a shape
|
;; group a shape
|
||||||
|
|
||||||
(t/deftest group-shapes-1
|
(t/deftest group-shapes-1
|
||||||
(let [initial {:pages {1 {:id 1 :shapes [1 2 3]}}
|
(let [initial {:pages {1 {:id 1 :shapes [1 2 3]}}
|
||||||
:shapes {1 {:id 1 :page 1}
|
:shapes {1 {:id 1 :page 1}
|
||||||
2 {:id 2 :page 1}
|
2 {:id 2 :page 1}
|
||||||
3 {:id 3 :page 1}}}
|
3 {:id 3 :page 1}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1 :shapes [1 4 3]}}
|
||||||
(assoc-in [:workspace :selected] #{4})
|
:shapes {1 {:id 1 :page 1}
|
||||||
(assoc-in [:pages 1 :shapes] [1 4 3])
|
2 {:id 2 :page 1 :group 4}
|
||||||
(assoc-in [:shapes 2 :group] 4)
|
3 {:id 3 :page 1}
|
||||||
(assoc-in [:shapes 4] {:type :group :name "Group-1"
|
4 {:type :group :name "Group-1" :items [2] :id 4 :page 1}}
|
||||||
:items [2] :id 4 :page 1}))]
|
:workspace {:selected #{4}}}]
|
||||||
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
||||||
(let [result (impl/group-shapes initial [2] 1)]
|
(let [result (impl/group-shapes initial [2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
(t/is (= result expected))))))
|
(t/is (= result expected))))))
|
||||||
|
|
||||||
|
|
||||||
;; group two shapes
|
;; group two shapes
|
||||||
|
|
||||||
(t/deftest group-shapes-2
|
(t/deftest group-shapes-2
|
||||||
|
@ -345,34 +348,32 @@
|
||||||
2 {:id 2 :page 1}
|
2 {:id 2 :page 1}
|
||||||
3 {:id 3 :page 1}}}
|
3 {:id 3 :page 1}}}
|
||||||
|
|
||||||
expected (-> initial
|
|
||||||
(assoc-in [:workspace :selected] #{4})
|
expected {:pages {1 {:id 1 :shapes [1 4]}}
|
||||||
(assoc-in [:pages 1 :shapes] [1 4])
|
:shapes {1 {:id 1 :page 1}
|
||||||
(assoc-in [:shapes 2 :group] 4)
|
2 {:id 2 :page 1 :group 4}
|
||||||
(assoc-in [:shapes 3 :group] 4)
|
3 {:id 3 :page 1 :group 4}
|
||||||
(assoc-in [:shapes 4] {:type :group :name "Group-1"
|
4 {:type :group :name "Group-1" :items [2 3] :id 4 :page 1}}
|
||||||
:items [2 3] :id 4 :page 1}))]
|
:workspace {:selected #{4}}}]
|
||||||
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
||||||
(let [result (impl/group-shapes initial [2 3] 1)]
|
(let [result (impl/group-shapes initial [2 3] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
;; (pprint result)
|
;; (pprint result)
|
||||||
(t/is (= result expected))))))
|
(t/is (= result expected))))))
|
||||||
|
|
||||||
|
|
||||||
;; group group
|
;; group group
|
||||||
|
|
||||||
(t/deftest group-shapes-3
|
(t/deftest group-shapes-3
|
||||||
(let [initial {:pages {1 {:id 1 :shapes [1 2 3]}}
|
(let [initial {:pages {1 {:id 1 :shapes [1 2 3]}}
|
||||||
:shapes {1 {:id 1 :page 1}
|
:shapes {1 {:id 1 :page 1}
|
||||||
2 {:id 2 :page 1}
|
2 {:id 2 :page 1}
|
||||||
3 {:id 3 :page 1 :type :group}}}
|
3 {:id 3 :page 1 :type :group}}}
|
||||||
|
expected {:pages {1 {:id 1 :shapes [1 4]}}
|
||||||
expected (-> initial
|
:shapes {1 {:id 1 :page 1}
|
||||||
(assoc-in [:workspace :selected] #{4})
|
2 {:id 2 :page 1 :group 4}
|
||||||
(assoc-in [:pages 1 :shapes] [1 4])
|
3 {:id 3 :page 1 :type :group :group 4}
|
||||||
(assoc-in [:shapes 2 :group] 4)
|
4 {:type :group :name "Group-1" :items [2 3] :id 4 :page 1}}
|
||||||
(assoc-in [:shapes 3 :group] 4)
|
:workspace {:selected #{4}}}]
|
||||||
(assoc-in [:shapes 4] {:type :group :name "Group-1"
|
|
||||||
:items [2 3] :id 4 :page 1}))]
|
|
||||||
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
||||||
(let [result (impl/group-shapes initial [2 3] 1)]
|
(let [result (impl/group-shapes initial [2 3] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
|
@ -387,13 +388,17 @@
|
||||||
2 {:id 2 :page 1 :group 3}
|
2 {:id 2 :page 1 :group 3}
|
||||||
3 {:id 3 :page 1 :type :group}}}
|
3 {:id 3 :page 1 :type :group}}}
|
||||||
|
|
||||||
expected (-> initial
|
expected {:pages {1 {:id 1 :shapes [1 3]}}
|
||||||
(assoc-in [:workspace :selected] #{4})
|
:shapes {1 {:id 1 :page 1}
|
||||||
(assoc-in [:pages 1 :shapes] [1 3])
|
2 {:id 2 :page 1 :group 4}
|
||||||
(assoc-in [:shapes 2 :group] 4)
|
3 {:id 3 :page 1 :type :group :items [4]}
|
||||||
(assoc-in [:shapes 3 :items] [4])
|
4 {:type :group
|
||||||
(assoc-in [:shapes 4] {:type :group :name "Group-1"
|
:name "Group-1"
|
||||||
:items [2] :id 4 :page 1 :group 3}))]
|
:items [2]
|
||||||
|
:id 4
|
||||||
|
:page 1
|
||||||
|
:group 3}}
|
||||||
|
:workspace {:selected #{4}}}]
|
||||||
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
(with-redefs [uxbox.util.uuid/random (constantly 4)]
|
||||||
(let [result (impl/group-shapes initial [2] 1)]
|
(let [result (impl/group-shapes initial [2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
|
@ -505,9 +510,9 @@
|
||||||
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
2 {:id 2 :page 1 :type :group :items [3] :group 1}
|
||||||
3 {:id 3 :page 1 :group 2}}}
|
3 {:id 3 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected {:pages {1 {:id 1, :shapes [1]}},
|
expected {:pages {1 {:id 1 :shapes [1]}}
|
||||||
:shapes {1 {:id 1, :page 1, :type :group, :items [3]},
|
:shapes {1 {:id 1 :page 1 :type :group :items [3]}
|
||||||
3 {:id 3, :page 1, :group 1}},
|
3 {:id 3 :page 1 :group 1}}
|
||||||
:workspace {:selected #{3}}}]
|
:workspace {:selected #{3}}}]
|
||||||
(let [result (impl/degroup-shapes initial [2] 1)]
|
(let [result (impl/degroup-shapes initial [2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
|
@ -523,8 +528,8 @@
|
||||||
3 {:id 3 :page 1 :group 1}
|
3 {:id 3 :page 1 :group 1}
|
||||||
4 {:id 4 :page 1 :group 2}}}
|
4 {:id 4 :page 1 :group 2}}}
|
||||||
|
|
||||||
expected {:pages {1 {:id 1, :shapes [3 4]}},
|
expected {:pages {1 {:id 1 :shapes [3 4]}}
|
||||||
:shapes {3 {:id 3, :page 1}, 4 {:id 4, :page 1}},
|
:shapes {3 {:id 3 :page 1} 4 {:id 4 :page 1}}
|
||||||
:workspace {:selected #{4 3}}}]
|
:workspace {:selected #{4 3}}}]
|
||||||
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
(let [result (impl/degroup-shapes initial [1 2] 1)]
|
||||||
;; (pprint expected)
|
;; (pprint expected)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue