Add color checks and test of event creation for fills

This commit is contained in:
Andrey Antukh
2025-06-05 13:18:41 +02:00
parent 8c54cb764f
commit 6719902647
3 changed files with 88 additions and 40 deletions

View File

@@ -0,0 +1,48 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.data.workspace-colors-test
(:require
[app.common.uuid :as uuid]
[app.main.data.workspace.colors :as dwc]
[clojure.test :as t]
[potok.v2.core :as ptk]))
(t/deftest build-change-fill-event
(let [color1 {:color "#fabada"
:opacity 1}
color2 {:color "#fabada"
:opacity 1
:ref-id uuid/zero
:ref-file uuid/zero}
color3 {:color "#fabada"
:opacity -1}
color4 {:opacity 1
:color "ffffff"}]
(t/is (ptk/event? (dwc/change-fill #{uuid/zero} color1 1)))
(t/is (ptk/event? (dwc/change-fill #{uuid/zero} color2 1)))
(t/is (thrown? js/Error
(ptk/event? (dwc/change-fill #{uuid/zero} color3 1))))
(t/is (thrown? js/Error
(ptk/event? (dwc/change-fill #{uuid/zero} color4 1))))))
(t/deftest build-add-fill-event
(let [color1 {:color "#fabada"
:opacity 1}
color2 {:color "#fabada"
:opacity 1
:ref-id uuid/zero
:ref-file uuid/zero}
color3 {:color "#fabada"
:opacity -1}
color4 {:opacity 1
:color "ffffff"}]
(t/is (ptk/event? (dwc/add-fill #{uuid/zero} color1 1)))
(t/is (ptk/event? (dwc/add-fill #{uuid/zero} color2 1)))
(t/is (thrown? js/Error
(ptk/event? (dwc/add-fill #{uuid/zero} color3 1))))
(t/is (thrown? js/Error
(ptk/event? (dwc/add-fill #{uuid/zero} color4 1))))))

View File

@@ -2,6 +2,7 @@
(:require
[cljs.test :as t]
[frontend-tests.basic-shapes-test]
[frontend-tests.data.workspace-colors-test]
[frontend-tests.helpers-shapes-test]
[frontend-tests.logic.comp-remove-swap-slots-test]
[frontend-tests.logic.components-and-tokens]
@@ -39,6 +40,7 @@
'frontend-tests.util-snap-data-test
'frontend-tests.util-simple-math-test
'frontend-tests.basic-shapes-test
'frontend-tests.data.workspace-colors-test
'frontend-tests.tokens.logic.token-actions-test
'frontend-tests.tokens.logic.token-data-test
'frontend-tests.tokens.import-export-test