mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Merge pull request #243 from tokens-studio/fix-tests
Temporary fix for tests
This commit is contained in:
commit
d7ee804ca3
1 changed files with 26 additions and 2 deletions
|
@ -1,8 +1,32 @@
|
||||||
(ns token-tests.helpers.state
|
(ns token-tests.helpers.state
|
||||||
(:require
|
(:require
|
||||||
|
[app.main.ui.workspace.tokens.style-dictionary :as sd]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
|
|
||||||
|
(defn end
|
||||||
|
"Apply `attributes` that match `token` for `shape-ids`.
|
||||||
|
|
||||||
|
Optionally remove attributes from `attributes-to-remove`,
|
||||||
|
this is useful for applying a single attribute from an attributes set
|
||||||
|
while removing other applied tokens from this set."
|
||||||
|
[]
|
||||||
|
(ptk/reify ::end
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ _ _]
|
||||||
|
(rx/empty))))
|
||||||
|
|
||||||
|
(defn end+
|
||||||
|
[]
|
||||||
|
(ptk/reify ::end+
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state _]
|
||||||
|
(->> (rx/from (sd/resolve-tokens+ (get-in state [:workspace-data :tokens])))
|
||||||
|
(rx/mapcat
|
||||||
|
(fn [_]
|
||||||
|
(rx/of
|
||||||
|
(end))))))))
|
||||||
|
|
||||||
(defn stop-on
|
(defn stop-on
|
||||||
"Helper function to be used with async version of run-store.
|
"Helper function to be used with async version of run-store.
|
||||||
|
|
||||||
|
@ -15,7 +39,7 @@
|
||||||
|
|
||||||
(def stop-on-send-update-indices
|
(def stop-on-send-update-indices
|
||||||
"Stops on `send-update-indices` function being called, which should be the last function of an event chain."
|
"Stops on `send-update-indices` function being called, which should be the last function of an event chain."
|
||||||
(stop-on :app.main.data.workspace.changes/send-update-indices))
|
(stop-on ::end))
|
||||||
|
|
||||||
;; Support for async events in tests
|
;; Support for async events in tests
|
||||||
;; https://chat.kaleidos.net/penpot-partners/pl/tz1yoes3w3fr9qanxqpuhoz3ch
|
;; https://chat.kaleidos.net/penpot-partners/pl/tz1yoes3w3fr9qanxqpuhoz3ch
|
||||||
|
@ -37,7 +61,7 @@
|
||||||
(js/console.log "[error]:" cause))
|
(js/console.log "[error]:" cause))
|
||||||
(fn [_]
|
(fn [_]
|
||||||
#_(js/console.log "[complete]"))))
|
#_(js/console.log "[complete]"))))
|
||||||
(doall (for [event events]
|
(doall (for [event (concat events [(end+)])]
|
||||||
(ptk/emit! store event)))
|
(ptk/emit! store event)))
|
||||||
(ptk/emit! store :the/end))))
|
(ptk/emit! store :the/end))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue