♻️ Refactor persistence layer

This commit is contained in:
Andrey Antukh 2023-07-25 11:20:52 +02:00
parent d679001955
commit 6436ef334b
62 changed files with 1030 additions and 1070 deletions

View file

@ -3,12 +3,13 @@
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.basic-shapes-test
(:require
[app.common.test-helpers.files :as cthf]
[app.common.test-helpers.ids-map :as cthi]
[app.common.test-helpers.shapes :as cths]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.shapes :as dwsh]
[cljs.test :as t :include-macros true]
[frontend-tests.helpers.state :as ths]))
@ -21,12 +22,12 @@
(-> (cthf/sample-file :file1 :page-label :page1)
(cths/add-sample-shape :shape1)))
;; ==== Action
;; ==== Action
events
[(dch/update-shapes [(cthi/id :shape1)]
#(assoc % :fills
(cths/sample-fills-color :fill-color
"#fabada")))]]
[(dwsh/update-shapes [(cthi/id :shape1)]
#(assoc % :fills
(cths/sample-fills-color :fill-color
"#fabada")))]]
(ths/run-store
store done events
@ -40,7 +41,7 @@
fills' (:fills shape1')
fill' (first fills')]
;; ==== Check
;; ==== Check
(t/is (some? shape1'))
(t/is (= (count fills') 1))
(t/is (= (:fill-color fill') "#fabada"))

View file

@ -30,7 +30,7 @@
event occurs, and then call the function with the final state at
this point."
[state done completed-cb]
(let [store (ptk/store {:state state :on-error on-error})
(let [store (ptk/store {:state state :on-error on-error})
stream (ptk/input-stream store)
stream (->> stream
(rx/take-until (rx/filter #(= :the/end %) stream))

View file

@ -38,21 +38,3 @@
{: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)))))