mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 06:20:32 +00:00
* 🐛 Fix tab on variant name doesn't validate formula * ✨ Move helpers to common * ✨ Mr proposed changes
43 lines
1.6 KiB
Clojure
43 lines
1.6 KiB
Clojure
;; 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 SUBSIDIARY SL
|
|
|
|
(ns common-tests.path-names-test
|
|
(:require
|
|
[app.common.path-names :as cpn]
|
|
[clojure.test :as t]))
|
|
|
|
(t/deftest split-group-name
|
|
(t/is (= ["foo" "bar"] (cpn/split-group-name "foo/bar")))
|
|
(t/is (= ["" "foo"] (cpn/split-group-name "foo")))
|
|
(t/is (= ["" "foo"] (cpn/split-group-name "/foo")))
|
|
(t/is (= ["" ""] (cpn/split-group-name "")))
|
|
(t/is (= ["" ""] (cpn/split-group-name nil))))
|
|
|
|
(t/deftest split-and-join-path
|
|
(let [name "group/subgroup/name"
|
|
path (cpn/split-path name :separator "/")
|
|
name' (cpn/join-path path :separator "/" :with-spaces? false)]
|
|
(t/is (= (first path) "group"))
|
|
(t/is (= (second path) "subgroup"))
|
|
(t/is (= (nth path 2) "name"))
|
|
(t/is (= name' name))))
|
|
|
|
(t/deftest split-and-join-path-with-spaces
|
|
(let [name "group / subgroup / name"
|
|
path (cpn/split-path name :separator "/")]
|
|
(t/is (= (first path) "group"))
|
|
(t/is (= (second path) "subgroup"))
|
|
(t/is (= (nth path 2) "name"))))
|
|
|
|
(t/deftest normalize-path-name
|
|
(t/is (= "Button" (cpn/normalize-path-name " Button ")))
|
|
(t/is (= "Group / Button" (cpn/normalize-path-name "Group / Button")))
|
|
(t/is (nil? (cpn/normalize-path-name nil)))
|
|
(t/is (nil? (cpn/normalize-path-name "")))
|
|
(t/is (nil? (cpn/normalize-path-name " ")))
|
|
(t/is (nil? (cpn/normalize-path-name "Button/")))
|
|
(t/is (nil? (cpn/normalize-path-name "Group / "))))
|