mirror of
https://github.com/penpot/penpot.git
synced 2025-07-26 02:37:22 +02:00
Fix tests.
This commit is contained in:
parent
ba0627c3ad
commit
b95c573fc2
3 changed files with 45 additions and 46 deletions
|
@ -1,42 +0,0 @@
|
||||||
(ns uxbox.data.workspace-tests
|
|
||||||
(:require [cljs.test :as t :include-macros true]
|
|
||||||
[cljs.pprint :refer (pprint)]
|
|
||||||
[uxbox.rstore :as rs]
|
|
||||||
[uxbox.data.workspace :as dw]))
|
|
||||||
|
|
||||||
;; delete shape: delete from page
|
|
||||||
(t/deftest delete-shape-test1
|
|
||||||
(let [initial {:pages-by-id {1 {:id 1 :shapes [1 3 4]}}
|
|
||||||
:shapes-by-id {1 {:id 1 :page 1
|
|
||||||
:type :builtin/group
|
|
||||||
:items [2]}
|
|
||||||
2 {:id 2 :page 1 :group 1}
|
|
||||||
3 {:id 3 :page 1}
|
|
||||||
4 {:id 4 :page 1}}}
|
|
||||||
event (dw/delete-shape 4)
|
|
||||||
expected (-> initial
|
|
||||||
(assoc-in [:pages-by-id 1 :shapes] [1 3])
|
|
||||||
(update-in [:shapes-by-id] dissoc 4))
|
|
||||||
result (rs/-apply-update event initial)]
|
|
||||||
;; (pprint expected)
|
|
||||||
;; (pprint result)
|
|
||||||
(t/is (= result expected))))
|
|
||||||
|
|
||||||
;; delete shape: delete from group
|
|
||||||
(t/deftest delete-shape-test2
|
|
||||||
(let [initial {:pages-by-id {1 {:id 1 :shapes [1 3 4]}}
|
|
||||||
:shapes-by-id {1 {:id 1 :page 1
|
|
||||||
:type :builtin/group
|
|
||||||
:items [2]}
|
|
||||||
2 {:id 2 :page 1 :group 1}
|
|
||||||
3 {:id 3 :page 1}
|
|
||||||
4 {:id 4 :page 1}}}
|
|
||||||
event (dw/delete-shape 2)
|
|
||||||
expected (-> initial
|
|
||||||
(assoc-in [:pages-by-id 1 :shapes] [3 4])
|
|
||||||
(update-in [:shapes-by-id] dissoc 2)
|
|
||||||
(update-in [:shapes-by-id] dissoc 1))
|
|
||||||
result (rs/-apply-update event initial)]
|
|
||||||
;; (pprint expected)
|
|
||||||
;; (pprint result)
|
|
||||||
(t/is (= result expected))))
|
|
|
@ -259,6 +259,49 @@
|
||||||
(assoc-in [:shapes-by-id 1 :items] [2 5])
|
(assoc-in [:shapes-by-id 1 :items] [2 5])
|
||||||
(update-in [:shapes-by-id 6] assoc :group 2))
|
(update-in [:shapes-by-id 6] assoc :group 2))
|
||||||
result (ssh/drop-shape initial 6 4 :after)]
|
result (ssh/drop-shape initial 6 4 :after)]
|
||||||
(pprint expected)
|
;; (pprint expected)
|
||||||
(pprint result)
|
;; (pprint result)
|
||||||
|
(t/is (= result expected))))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Delete Shape
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;; delete shape: delete from page
|
||||||
|
|
||||||
|
(t/deftest delete-shape-test1
|
||||||
|
(let [initial {:pages-by-id {1 {:id 1 :shapes [1 3 4]}}
|
||||||
|
:shapes-by-id {1 {:id 1 :page 1
|
||||||
|
:type :builtin/group
|
||||||
|
:items [2]}
|
||||||
|
2 {:id 2 :page 1 :group 1}
|
||||||
|
3 {:id 3 :page 1}
|
||||||
|
4 {:id 4 :page 1}}}
|
||||||
|
|
||||||
|
shape (get-in initial [:shapes-by-id 4])
|
||||||
|
expected (-> initial
|
||||||
|
(assoc-in [:pages-by-id 1 :shapes] [1 3])
|
||||||
|
(update-in [:shapes-by-id] dissoc 4))
|
||||||
|
result (ssh/dissoc-shape initial shape)]
|
||||||
|
;; (pprint expected)
|
||||||
|
;; (pprint result)
|
||||||
|
(t/is (= result expected))))
|
||||||
|
|
||||||
|
;; delete shape: delete from group
|
||||||
|
(t/deftest delete-shape-test2
|
||||||
|
(let [initial {:pages-by-id {1 {:id 1 :shapes [1 3 4]}}
|
||||||
|
:shapes-by-id {1 {:id 1 :page 1
|
||||||
|
:type :builtin/group
|
||||||
|
:items [2]}
|
||||||
|
2 {:id 2 :page 1 :group 1}
|
||||||
|
3 {:id 3 :page 1}
|
||||||
|
4 {:id 4 :page 1}}}
|
||||||
|
shape (get-in initial [:shapes-by-id 2])
|
||||||
|
expected (-> initial
|
||||||
|
(assoc-in [:pages-by-id 1 :shapes] [3 4])
|
||||||
|
(update-in [:shapes-by-id] dissoc 2)
|
||||||
|
(update-in [:shapes-by-id] dissoc 1))
|
||||||
|
result (ssh/dissoc-shape initial shape)]
|
||||||
|
;; (pprint expected)
|
||||||
|
;; (pprint result)
|
||||||
(t/is (= result expected))))
|
(t/is (= result expected))))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(ns uxbox.test-runner
|
(ns uxbox.test-runner
|
||||||
(:require [cljs.test :as test]
|
(:require [cljs.test :as test]
|
||||||
[uxbox.state.shapes-tests]
|
[uxbox.state.shapes-tests]
|
||||||
[uxbox.data.workspace-tests]
|
|
||||||
[uxbox.util.geom-tests]))
|
[uxbox.util.geom-tests]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
@ -10,7 +9,6 @@
|
||||||
[]
|
[]
|
||||||
(test/run-tests
|
(test/run-tests
|
||||||
(test/empty-env)
|
(test/empty-env)
|
||||||
'uxbox.data.workspace-tests
|
|
||||||
'uxbox.util.geom-tests
|
'uxbox.util.geom-tests
|
||||||
'uxbox.state.shapes-tests
|
'uxbox.state.shapes-tests
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue