mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 21:48:29 +02:00
⚡ Optimize point functions
This commit is contained in:
parent
c28534555b
commit
fc4e755f2b
8 changed files with 589 additions and 155 deletions
|
@ -297,8 +297,8 @@
|
|||
(mapv (fn [[value points]]
|
||||
[(- value pval)
|
||||
(->> points (mapv #(vector point %)))])))))]
|
||||
{:x (query-coord point :x)
|
||||
:y (query-coord point :y)}))
|
||||
(gpt/point (query-coord point :x)
|
||||
(query-coord point :y))))
|
||||
|
||||
(defn merge-matches
|
||||
([] {:x nil :y nil})
|
||||
|
|
53
frontend/test/frontend_tests/test_helpers_shapes.cljs
Normal file
53
frontend/test/frontend_tests/test_helpers_shapes.cljs
Normal file
|
@ -0,0 +1,53 @@
|
|||
(ns frontend-tests.test-helpers-shapes
|
||||
(:require
|
||||
[app.common.colors :as clr]
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.test-helpers.events :as the]
|
||||
[app.test-helpers.libraries :as thl]
|
||||
[app.test-helpers.pages :as thp]
|
||||
[beicon.core :as rx]
|
||||
[cljs.pprint :refer [pprint]]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[clojure.stacktrace :as stk]
|
||||
[linked.core :as lks]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(t/use-fixtures :each
|
||||
{:before thp/reset-idmap!})
|
||||
|
||||
(t/deftest test-create-page
|
||||
(t/testing "create page"
|
||||
(let [state (-> thp/initial-state
|
||||
(thp/sample-page))
|
||||
page (thp/current-page state)]
|
||||
(t/is (= (:name page) "page1")))))
|
||||
|
||||
(t/deftest test-create-shape
|
||||
(t/testing "create shape"
|
||||
(let [state (-> thp/initial-state
|
||||
(thp/sample-page)
|
||||
(thp/sample-shape :shape1 :rect
|
||||
{:name "Rect 1"}))
|
||||
shape (thp/get-shape state :shape1)]
|
||||
(t/is (= (:name shape) "Rect 1")))))
|
||||
|
||||
(t/deftest asynctest
|
||||
(t/testing "asynctest"
|
||||
(t/async done
|
||||
(let [state {}
|
||||
color {:color clr/white}
|
||||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
(t/is (= (get-in new-state [:workspace-data
|
||||
:recent-colors])
|
||||
[color]))))]
|
||||
|
||||
(ptk/emit!
|
||||
store
|
||||
(dwl/add-recent-color color)
|
||||
:the/end)))))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue