1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-07 02:33:39 +02:00
airsonic-ui/test/cljs/airsonic_ui/helpers_test.cljs
Arne Schlüter 5cbb83a22d Add user role checks, see #14
Squashed commit of the following:

commit 393c481a21fa97881be2b6859e9acaa8ab7abb7f
Author: Arne Schlüter <arne@schlueter.is>
Date:   Wed Sep 5 12:04:56 2018 +0200

    Consider user roles when building up the navigation

commit d631cba1174ecf42b682664bf57c41b88b7f5ed4
Author: Arne Schlüter <arne@schlueter.is>
Date:   Wed Sep 5 11:52:05 2018 +0200

    Save user roles on login

commit e68ced335ccc11a2daebbf12bb4061a53935c268
Author: Arne Schlüter <arne@schlueter.is>
Date:   Wed Sep 5 10:25:19 2018 +0200

    Rename dispatch to muted-dispatch for easier disambiguation
2018-09-05 12:06:07 +02:00

33 lines
1.8 KiB
Clojure

(ns airsonic-ui.helpers-test
(:require [cljs.test :refer [deftest testing is]]
[airsonic-ui.helpers :as helpers]))
(deftest find-where
(testing "Finds the correct item and index"
(is (= [0 1] (helpers/find-where (partial = 1) (range 1 10))))
(is (= [2 {:foo true, :bar false}] (helpers/find-where :foo '({}
{:foo false
:bar true}
{:foo true
:bar false})))))
(testing "Returns nil when nothing is found"
(is (nil? (helpers/find-where (partial = 2) (range 2))))))
(deftest add-classes
(testing "Should add classes to a simple hiccup keyword"
(is (= :div.foo (helpers/add-classes :div :foo)))
(is (= :div.bar.bar (helpers/add-classes :div.bar :bar)))
(is (= :div.foo.bar (helpers/add-classes :div.foo :bar))))
(testing "Should add classes to the innermost child of a nested hiccup element"
(is (= :p>input.input (helpers/add-classes :p>input :input)))
(is (= :div.field>p>input.input.has-background-red (helpers/add-classes :div.field>p>input.input :has-background-red)))))
(deftest kebabify
(testing "Should turn camelCased and PascalCased strings into kebab-cased keywords"
(is (= :hello-world (helpers/kebabify "HelloWorld")))
(is (= :how-are-you (helpers/kebabify "howAreYou")))
(is (= :foobar (helpers/kebabify "foobar"))))
(testing "Should kebab-case camelCased and PascalCased keywords"
(is (= :hello-world (helpers/kebabify :HelloWorld)))
(is (= :how-are-you (helpers/kebabify :howAreYou)))
(is (= :foobar (helpers/kebabify :foobar)))))