2021-11-24 06:37:55 -05:00
|
|
|
;; 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/.
|
|
|
|
;;
|
2022-11-02 12:11:50 -05:00
|
|
|
;; Copyright (c) KALEIDOS INC
|
2021-11-24 06:37:55 -05:00
|
|
|
|
2022-11-08 04:40:19 -05:00
|
|
|
(ns common-tests.pages-helpers-test
|
2021-11-24 06:37:55 -05:00
|
|
|
(:require
|
|
|
|
[clojure.test :as t]
|
|
|
|
[clojure.pprint :refer [pprint]]
|
|
|
|
[app.common.pages.helpers :as cph]))
|
|
|
|
|
|
|
|
(t/deftest insert-at-index
|
|
|
|
;; insert different object
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 1 [:c :d])
|
|
|
|
[:a :c :d :b]))
|
|
|
|
|
|
|
|
;; insert on the start
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 0 [:c])
|
|
|
|
[:c :a :b]))
|
|
|
|
|
|
|
|
;; insert on the end 1
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 2 [:c])
|
|
|
|
[:a :b :c]))
|
|
|
|
|
|
|
|
;; insert on the end with not existing index
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 10 [:c])
|
|
|
|
[:a :b :c]))
|
|
|
|
|
:wrench: Fix typos in source code
Found via `codespell -q 3 -S *.po,./frontend/yarn.lock -L childs,clen,fpr,inflight,ody,ot,ro,te,trys,ue`
2022-10-02 13:00:19 -05:00
|
|
|
;; insert existing in a contiguous index
|
2021-11-24 06:37:55 -05:00
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 1 [:a])
|
2021-12-03 10:00:56 -05:00
|
|
|
[:a :b]))
|
2021-11-24 06:37:55 -05:00
|
|
|
|
|
|
|
;; insert existing in the same index
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b] 0 [:a])
|
|
|
|
[:a :b]))
|
|
|
|
|
|
|
|
;; insert existing in other index case 1
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b :c] 2 [:a])
|
2021-12-03 10:00:56 -05:00
|
|
|
[:b :a :c]))
|
2021-11-24 06:37:55 -05:00
|
|
|
|
|
|
|
;; insert existing in other index case 2
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b :c :d] 0 [:d])
|
|
|
|
[:d :a :b :c]))
|
|
|
|
|
|
|
|
;; insert existing in other index case 3
|
|
|
|
(t/is (= (cph/insert-at-index [:a :b :c :d] 1 [:a])
|
2021-12-03 10:00:56 -05:00
|
|
|
[:a :b :c :d]))
|
2021-11-24 06:37:55 -05:00
|
|
|
|
|
|
|
)
|
2021-12-09 11:35:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
(t/deftest parse-path-name
|
|
|
|
(t/is (= ["foo" "bar"] (cph/parse-path-name "foo/bar")))
|
|
|
|
(t/is (= ["" "foo"] (cph/parse-path-name "foo")))
|
|
|
|
(t/is (= ["" "foo"] (cph/parse-path-name "/foo")))
|
|
|
|
(t/is (= ["" ""] (cph/parse-path-name "")))
|
|
|
|
(t/is (= ["" ""] (cph/parse-path-name nil)))
|
|
|
|
)
|