1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-07 10:43:39 +02:00

Add skipping for linear playlists with all repeat modes

This commit is contained in:
Arne Schlüter 2018-08-07 15:15:13 +02:00
commit d7b8cbcc4e
3 changed files with 99 additions and 32 deletions

View file

@ -2,7 +2,8 @@
(:require [cljs.test :refer [deftest testing is]]
[airsonic-ui.audio.playlist :as playlist]
[airsonic-ui.fixtures :as fixtures]
[airsonic-ui.test-helpers :as helpers]))
[airsonic-ui.test-helpers :as helpers]
[debux.cs.core :refer-macros [dbg]]))
(enable-console-print!)
@ -90,14 +91,47 @@
(str "from " repeat-mode " to " next-repeat-mode)))))))
(deftest linear-next-song
(testing "Should follow the same order as the queue used for creation")
(testing "Should go back to the first song when repeat-mode is all")
(testing "Should always give the same track when repeat-mode is single"))
(testing "Should follow the same order as the queue used for creation"
(doseq [repeat-mode [:repeat-mode/none :repeat-mode/all]]
(let [queue (playing-queue 5)
playlist (playlist/->playlist queue 0 :playback-mode/linear repeat-mode)]
(is (same-song? (nth queue 1) (-> (playlist/next-song playlist)
(playlist/peek)))
(str repeat-mode ", skipped once"))
(is (same-song? (nth queue 2) (-> (playlist/next-song playlist)
(playlist/next-song)
(playlist/peek)))
(str repeat-mode ", skipped twice")))))
(testing "Should go back to the first song when repeat-mode is all and we played the last song")
(testing "Should always give the same track when repeat-mode is single"
(let [queue (playing-queue 3)
playing-idx (rand-int 3)
playlist (playlist/->playlist queue playing-idx :playback-mode/linear :repeat-mode/single)]
(is (same-song? (nth queue playing-idx) (playlist/peek playlist)))
(is (same-song? (nth queue playing-idx)
(-> (playlist/next-song playlist)
(playlist/peek))))
(is (same-song? (nth queue playing-idx)
(-> (playlist/next-song playlist)
(playlist/next-song)
(playlist/peek))))
(is (same-song? (nth queue playing-idx)
(-> (playlist/next-song playlist)
(playlist/next-song)
(playlist/next-song)
(playlist/peek)))
"wrapping around")))
(testing "Should stop playing at the end of the queue when repeat-mode is none"
(is (nil? (-> (playing-queue 1)
(playlist/->playlist 0 :playback-mode/linear :repeat-mode/none)
(playlist/next-song)
(playlist/peek))))))
(deftest shuffled-next-song
#_(deftest shuffled-next-song
(testing "Should play every track once when called for the entire queue")
(testing "Should re-shuffle the playlist when wrapping around and repeat-mode is all")
(testing "Should always give the same track when repeat-mode is single"))
(testing "Should always give the same track when repeat-mode is single")
(testing "Should stop playing at the end of the queue when repeat-mode is none"))
#_(deftest linear-previous-song)
#_(deftest shuffled-previous-song)