mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Start restructuring audio playback, add some tests for audio
Fixes #15 where audio was not stopped on logout
This commit is contained in:
parent
727d454871
commit
80225d46b1
10 changed files with 187 additions and 69 deletions
40
test/cljs/airsonic_ui/audio_test.cljs
Normal file
40
test/cljs/airsonic_ui/audio_test.cljs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
(ns airsonic-ui.audio-test
|
||||
(:require [airsonic-ui.audio :as audio]
|
||||
[airsonic-ui.fixtures :as fixtures]
|
||||
[airsonic-ui.test-helpers :as helpers]
|
||||
[cljs.test :refer [deftest testing is]]))
|
||||
|
||||
(enable-console-print!)
|
||||
|
||||
(defn- simulate-playlist [n ]
|
||||
(repeatedly n #(hash-map :id (rand-int 9999)
|
||||
:coverArt (rand-int 9999)
|
||||
:year (+ 1900 (rand-int 118))
|
||||
:artist (helpers/rand-str)
|
||||
:aristId (rand-int 100000)
|
||||
:title (helpers/rand-str)
|
||||
:album (helpers/rand-str))))
|
||||
|
||||
(def fixture
|
||||
{:audio {:current-song fixtures/song
|
||||
:playlist (simulate-playlist 20)
|
||||
:playback-status fixtures/playback-status}})
|
||||
|
||||
(deftest current-song
|
||||
(letfn [(current-song [db]
|
||||
(-> (audio/summary db [:audio/summary])
|
||||
(audio/current-song [:audio/current-song])))]
|
||||
(testing "Should provide information about the song"
|
||||
(= fixtures/song (current-song fixture)))))
|
||||
|
||||
(deftest playback-status
|
||||
(letfn [(is-playing? [playback-status]
|
||||
(audio/is-playing? playback-status [:audio/is-playing?]))]
|
||||
(testing "Should be shown as not playing when the song is paused or has ended"
|
||||
(is (not (is-playing? {:paused? true, :ended? false})))
|
||||
(is (not (is-playing? {:paused? false, :ended? true}))))
|
||||
(testing "Should be shown as playing when the song is not paused or finished"
|
||||
(is (is-playing? {:paused? false, :ended? false})))))
|
||||
|
||||
#_(deftest current-playlist
|
||||
(testing "Should show the complete playlist"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue