mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Closes #21. Squashed commit of the following: commit 964b29cf127cf51de86543d040bcb6c674b36d7e Author: Arne Schlüter <arne@schlueter.is> Date: Wed Aug 22 17:56:48 2018 +0200 Pass content for current route nicely to views commit b469a0a4b69457ddf3a679ac1acc82fbaffdc8fd Author: Arne Schlüter <arne@schlueter.is> Date: Wed Aug 22 16:01:04 2018 +0200 Add response cache in app-db commit da9faf89138f42ee544efc64c2e46787091b3dc7 Author: Arne Schlüter <arne@schlueter.is> Date: Wed Aug 22 13:40:57 2018 +0200 Move api helpers and tests to own namespace
29 lines
1.5 KiB
Clojure
29 lines
1.5 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 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]))))))
|