1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-07 10:43:39 +02:00
airsonic-ui/test/cljs/airsonic_ui/helpers_test.cljs
heyarne 8bf222a6e8
Improvements to currently playing queue (#48)
* First sloppy import of code from heyarne/reagent-movable

* Consistently use "current queue" to avoid confusion

* Update shadow-cljs, re-frame and debux

* Solve styling problem when sorting table rows

* Make sortable component more reusable

* Refactor playlist to use a sorted-map

* Make sure current queue is displayed again

* Fix sorting when converting a shuffled into a linear playlist

* Implement set-current-track

* Implement song-move in playlist

* Add autoprefixer

* Implement drag and drop reordering in current queue

* Fix broken dev sass build

* Bump some dependencies

* Move airsonic-ui.views.icon to bulma.icon

* Implement reusable dropdown in bulma.dropdown

* Immediately render reordered tracks, reimplement actions in album view

* Use new song-table on search result page

* Make song-table more reusable

* Remove current song

* Implement go to source in current queue

* Remove unused song view
2019-03-12 15:22:13 +01:00

34 lines
1.7 KiB
Clojure

(ns airsonic-ui.helpers-test
(:require [cljs.test :refer [deftest testing is]]
[airsonic-ui.helpers :as helpers]))
(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)))))
(deftest format-duration
(testing "Should format hours, minutes and seconds"
(is (= "1h" (helpers/format-duration 3600)))
(is (= "59m" (helpers/format-duration (* 59 60))))
(is (= "1m" (helpers/format-duration 60)))
(is (= "5s" (helpers/format-duration 5))))
(testing "Should respect the :brief? option"
(is (= "01:00:00" (helpers/format-duration 3600 :brief? true)))
(is (= "59:00" (helpers/format-duration (* 59 60) :brief? true)))
(is (= "01:00" (helpers/format-duration 60 :brief? true)))
(is (= "00:05" (helpers/format-duration 5 :brief? true)))))