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/bulma/dropdown_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

40 lines
2.3 KiB
Clojure

(ns bulma.dropdown-test
(:require [cljs.test :refer-macros [deftest testing is]]
[bulma.dropdown.subs :as sub]
[bulma.dropdown.events :as ev]))
;; NOTE: Here as well; this code is very much like the modal code
;; Not sure whether to explicitly duplicate it or provide some smarter
;; abstraction that's harder to understand at first sight
(enable-console-print!)
(deftest bulma-dropdowns
(testing "Should create a collection of dropdowns if there is none"
(let [new-db (ev/show-dropdown {} [::ev/show :some-dropdown-id])]
(is (= :some-dropdown-id (sub/visible-dropdown new-db [::sub/visible-dropdown])))))
(testing "Should hide other dropdowns when displaying a new one"
(let [dropdown-ids [:some-id-1 :some-id-2 :some-id-3]
new-db (reduce (fn [db dropdown-id]
(ev/show-dropdown db [::ev/show dropdown-id]))
{} dropdown-ids)]
(is (= :some-id-3 (sub/visible-dropdown new-db [::sub/visible-dropdown])))))
(testing "Should remove a dropdown from the collection when we hide it"
(let [dropdown-ids [:some-id-1 :some-id-2 :some-id-3]
new-db (-> (reduce (fn [db dropdown-id]
(ev/show-dropdown db [::ev/show dropdown-id]))
{} dropdown-ids)
(ev/hide-dropdown [::ev/hide]))]
(is (not (some? (sub/visible-dropdown new-db [::sub/visible-dropdown]))))))
(testing "Should tell us about the visibility of a dropdown with a predicate"
(is (true? (-> (ev/show-dropdown {} [::ev/show :getting-repetitive])
(sub/visible-dropdown [::sub/visible-dropdown])
(sub/visible? [::sub/visible? :getting-repetitive])))))
(testing "Dropdown toggling"
(is (true? (-> (ev/toggle-dropdown {} [::ev/toggle :some-generic-dropdown])
(sub/visible-dropdown [::sub/visible-dropdown])
(sub/visible? [::sub/visible? :some-generic-dropdown]))))
(is (not (true? (-> (ev/toggle-dropdown {} [::ev/toggle :some-generic-dropdown])
(ev/toggle-dropdown [::ev/toggle :some-generic-dropdown])
(sub/visible-dropdown [::sub/visible-dropdown])
(sub/visible? [::sub/visible? :some-generic-dropdown])))))))