mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 07:48:29 +02:00
Restrict token naming
This commit is contained in:
parent
5c5b378262
commit
f9530c5a10
2 changed files with 54 additions and 1 deletions
26
frontend/test/token_tests/token_form_test.cljs
Normal file
26
frontend/test/token_tests/token_form_test.cljs
Normal file
|
@ -0,0 +1,26 @@
|
|||
;; 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 token-tests.token-form-test
|
||||
(:require
|
||||
[app.main.ui.workspace.tokens.form :as wtf]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[malli.core :as m]))
|
||||
|
||||
(t/deftest test-valid-token-name-schema
|
||||
;; Allow regular namespace token names
|
||||
(t/is (some? (m/validate wtf/valid-token-name-schema "Foo")))
|
||||
(t/is (some? (m/validate wtf/valid-token-name-schema "foo")))
|
||||
(t/is (some? (m/validate wtf/valid-token-name-schema "FOO")))
|
||||
(t/is (some? (m/validate wtf/valid-token-name-schema "Foo.Bar.Baz")))
|
||||
;; Allow trailing tokens
|
||||
(t/is (nil? (m/validate wtf/valid-token-name-schema "Foo.Bar.Baz....")))
|
||||
;; Disallow multiple separator dots
|
||||
(t/is (nil? (m/validate wtf/valid-token-name-schema "Foo..Bar.Baz")))
|
||||
;; Disallow any special characters
|
||||
(t/is (nil? (m/validate wtf/valid-token-name-schema "Hey Foo.Bar")))
|
||||
(t/is (nil? (m/validate wtf/valid-token-name-schema "Hey😈Foo.Bar")))
|
||||
(t/is (nil? (m/validate wtf/valid-token-name-schema "Hey%Foo.Bar"))))
|
Loading…
Add table
Add a link
Reference in a new issue