mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Squashed commit of the following:
commit 8a19df91f8daa1b791d40cc910947c94355a8d0d
Author: Arne Schlüter <arne@schlueter.is>
Date: Tue Aug 28 16:06:35 2018 +0200
Implement search UI (closes #19)
commit bf661dd25ec9f1d5569df88a8a87f94c1bc1b317
Author: Arne Schlüter <arne@schlueter.is>
Date: Tue Aug 28 11:09:46 2018 +0200
Re-add subscription for single endpoint and move helpers to a different location
35 lines
1.9 KiB
Clojure
35 lines
1.9 KiB
Clojure
(ns airsonic-ui.api.subs-test
|
|
(:require [cljs.test :refer-macros [deftest testing is]]
|
|
[airsonic-ui.api.subs :as sub]))
|
|
|
|
(enable-console-print!)
|
|
|
|
(deftest single-response
|
|
(testing "Should return the response for a specified endpoint"
|
|
(let [db {:api/responses {["search2" {:query "query term"}] :result}}]
|
|
(is (= :result (sub/response-for db [:api/response-for "search2" {:query "query term"}])))
|
|
(is (nil? (sub/response-for db [:api/response-for "search2" {:query "another query term"}]))))))
|
|
|
|
(deftest endpoint-keywordification
|
|
(testing "Should strip prefixes"
|
|
(is (= :artist-info (sub/endpoint->kw "getArtistInfo")))
|
|
(is (= :jukebox-control (sub/endpoint->kw "jukeboxControl"))))
|
|
(testing "Should strip trailing numbers"
|
|
(is (= :album-list (sub/endpoint->kw "getAlbumList2")))
|
|
(is (= :search (sub/endpoint->kw "search3")))))
|
|
|
|
(deftest responses-for-route
|
|
(testing "Should return all cached responses for a route"
|
|
(let [route-events [[:api/request "getAlbumList2" {:type "recent", :size 18}]
|
|
[:event/should-be-ignored]
|
|
[:api/request "getArtistInfo" {:id "128"}]]
|
|
db {:api/responses {["getAlbumList2" {:type "recent" :size 18}]
|
|
{:album [{:genre "foo", :artistId "12345"}
|
|
{:genre "electronic", :artistId "9999"}]}
|
|
|
|
["getArtistInfo" {:id "128"}]
|
|
{:biography "Interesting bio"
|
|
:largeImageUrl "https://lastfm-img2.akamaized.net/i/u/300x300/fb416b59cd694587aca0b2dec8f41198.png"}}}]
|
|
(is (= {:album-list (get-in db [:api/responses ["getAlbumList2" {:type "recent" :size 18}]])
|
|
:artist-info (get-in db [:api/responses ["getArtistInfo" {:id "128"}]])}
|
|
(sub/route-data db [:api/route-data route-events]))))))
|