diff --git a/frontend/test/token_tests/token_test.cljs b/frontend/test/token_tests/token_test.cljs index 618dc9a21..2767bf335 100644 --- a/frontend/test/token_tests/token_test.cljs +++ b/frontend/test/token_tests/token_test.cljs @@ -9,6 +9,29 @@ [app.main.ui.workspace.tokens.token :as wtt] [cljs.test :as t :include-macros true])) +(t/deftest token-applied-test + (t/testing "matches passed token with `:token-attributes`" + (t/is (true? (wtt/token-applied? {:id :a} {:applied-tokens {:x :a}} #{:x})))) + (t/testing "doesn't match empty token" + (t/is (nil? (wtt/token-applied? {} {:applied-tokens {:x :a}} #{:x})))) + (t/testing "does't match passed token `:id`" + (t/is (nil? (wtt/token-applied? {:id :b} {:applied-tokens {:x :a}} #{:x})))) + (t/testing "doesn't match passed `:token-attributes`" + (t/is (nil? (wtt/token-applied? {:id :a} {:applied-tokens {:x :a}} #{:y}))))) + +(t/deftest tokens-applied-test + (t/testing "is true when single shape matches the token and attributes" + (t/is (true? (wtt/tokens-applied? {:id :a} [{:applied-tokens {:x :a}} + {:applied-tokens {:x :b}}] + #{:x})))) + (t/testing "is false when no shape matches the token or attributes" + (t/is (nil? (wtt/tokens-applied? {:id :a} [{:applied-tokens {:x :b}} + {:applied-tokens {:x :b}}] + #{:x}))) + (t/is (nil? (wtt/tokens-applied? {:id :a} [{:applied-tokens {:x :a}} + {:applied-tokens {:x :a}}] + #{:y}))))) + (t/deftest name->path-test (t/is (= ["foo" "bar" "baz"] (wtt/token-name->path "foo.bar.baz"))) (t/is (= ["foo" "bar" "baz"] (wtt/token-name->path "foo..bar.baz")))