mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 00:41:25 -05:00
Add tests
This commit is contained in:
parent
93a23c66ec
commit
3413d4b42f
2 changed files with 37 additions and 17 deletions
frontend
|
@ -59,23 +59,6 @@
|
|||
(or temp-theme-id-set #{})
|
||||
new-themes)))
|
||||
|
||||
(comment
|
||||
(let [state {:workspace-data {:token-themes-index {1 {:id 1}}}}]
|
||||
(toggle-active-theme-id 1 state))
|
||||
|
||||
(let [state {:workspace-data {:token-active-themes #{1}
|
||||
:token-themes-index {1 {:id 1}}}}]
|
||||
(toggle-active-theme-id 1 state))
|
||||
|
||||
(let [state {:workspace-data {:token-active-themes #{2 3 4}
|
||||
:token-themes-index {1 {:id 1}
|
||||
2 {:id 2}
|
||||
3 {:id 3}
|
||||
4 {:id 4 :group :different}}}}]
|
||||
(toggle-active-theme-id 1 state))
|
||||
nil)
|
||||
|
||||
|
||||
(defn update-theme-id
|
||||
[state]
|
||||
(let [active-themes (get-active-theme-ids state)
|
||||
|
|
37
frontend/test/token_tests/token_set_test.cljs
Normal file
37
frontend/test/token_tests/token_set_test.cljs
Normal file
|
@ -0,0 +1,37 @@
|
|||
(ns token-tests.token-set-test
|
||||
(:require
|
||||
[app.main.ui.workspace.tokens.token-set :as wtts]
|
||||
[cljs.test :as t]))
|
||||
|
||||
(t/deftest toggle-active-theme-id-test
|
||||
(t/testing "toggles active theme id"
|
||||
(let [state {:workspace-data {:token-themes-index {1 {:id 1}}}}]
|
||||
(t/testing "activates theme with id")
|
||||
(t/is (= (wtts/toggle-active-theme-id 1 state) #{1})))
|
||||
|
||||
(let [state {:workspace-data {:token-active-themes #{1}
|
||||
:token-themes-index {1 {:id 1}}}}]
|
||||
(t/testing "missing temp theme returns empty set"
|
||||
(t/is (= #{} (wtts/toggle-active-theme-id 1 state)))))
|
||||
|
||||
(let [state {:workspace-data {:token-theme-temporary-id :temp
|
||||
:token-active-themes #{1}
|
||||
:token-themes-index {1 {:id 1}}}}]
|
||||
(t/testing "empty set returns temp theme"
|
||||
(t/is (= #{:temp} (wtts/toggle-active-theme-id 1 state)))))
|
||||
|
||||
(let [state {:workspace-data {:token-active-themes #{2 3 4}
|
||||
:token-themes-index {1 {:id 1}
|
||||
2 {:id 2}
|
||||
3 {:id 3}
|
||||
4 {:id 4 :group :different}}}}]
|
||||
(t/testing "removes same group themes and keeps different group themes"
|
||||
(t/is (= #{1 4} (wtts/toggle-active-theme-id 1 state)))))
|
||||
|
||||
(let [state {:workspace-data {:token-active-themes #{1 2 3 4}}
|
||||
:token-themes-index {1 {:id 1}
|
||||
2 {:id 2}
|
||||
3 {:id 3}
|
||||
4 {:id 4 :group :different}}}]
|
||||
(t/testing "removes theme when active"
|
||||
(t/is (= #{4 3 2} (wtts/toggle-active-theme-id 1 state)))))))
|
Loading…
Add table
Reference in a new issue