mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🔧 Unify path name helper functions
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
;; 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 common-tests.pages-helpers-test
|
||||
(:require
|
||||
[app.common.files.helpers :as cfh]
|
||||
[clojure.pprint :refer [pprint]]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/deftest parse-path-name
|
||||
(t/is (= ["foo" "bar"] (cfh/parse-path-name "foo/bar")))
|
||||
(t/is (= ["" "foo"] (cfh/parse-path-name "foo")))
|
||||
(t/is (= ["" "foo"] (cfh/parse-path-name "/foo")))
|
||||
(t/is (= ["" ""] (cfh/parse-path-name "")))
|
||||
(t/is (= ["" ""] (cfh/parse-path-name nil))))
|
||||
|
||||
33
common/test/common_tests/path_names_test.cljc
Normal file
33
common/test/common_tests/path_names_test.cljc
Normal file
@@ -0,0 +1,33 @@
|
||||
;; 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 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"))))
|
||||
@@ -30,7 +30,7 @@
|
||||
[common-tests.logic.swap-as-override-test]
|
||||
[common-tests.logic.token-test]
|
||||
[common-tests.media-test]
|
||||
[common-tests.pages-helpers-test]
|
||||
[common-tests.path-names-test]
|
||||
[common-tests.record-test]
|
||||
[common-tests.schema-test]
|
||||
[common-tests.svg-path-test]
|
||||
@@ -81,7 +81,7 @@
|
||||
'common-tests.logic.swap-as-override-test
|
||||
'common-tests.logic.token-test
|
||||
'common-tests.media-test
|
||||
'common-tests.pages-helpers-test
|
||||
'common-tests.path-names-test
|
||||
'common-tests.record-test
|
||||
'common-tests.schema-test
|
||||
'common-tests.svg-path-test
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#?(:clj [app.common.test-helpers.tokens :as tht])
|
||||
#?(:clj [clojure.datafy :refer [datafy]])
|
||||
[app.common.data :as d]
|
||||
[app.common.path-names :as cpn]
|
||||
[app.common.test-helpers.ids-map :as thi]
|
||||
[app.common.time :as ct]
|
||||
[app.common.transit :as tr]
|
||||
@@ -872,22 +873,6 @@
|
||||
(t/is (= (ctob/set-count tokens-lib') 1))
|
||||
(t/is (= (ctob/theme-count tokens-lib') 2)))))
|
||||
|
||||
(t/deftest split-and-join-path
|
||||
(let [name "group/subgroup/name"
|
||||
path (ctob/split-path name "/")
|
||||
name' (ctob/join-path path "/")]
|
||||
(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 (ctob/split-path name "/")]
|
||||
(t/is (= (first path) "group"))
|
||||
(t/is (= (second path) "subgroup"))
|
||||
(t/is (= (nth path 2) "name"))))
|
||||
|
||||
(t/deftest add-tokens-in-set
|
||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
||||
(ctob/add-set (ctob/make-token-set :id (thi/new-id! :test-token-set)
|
||||
|
||||
Reference in New Issue
Block a user