mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Add loading indicator to breadcrumbs (#29)
Also moves the current route data into a level 3 subscription (finally).
This commit is contained in:
parent
10f2e32ecd
commit
ec4504e475
5 changed files with 83 additions and 35 deletions
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
(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"}]))))))
|
||||
(let [responses (sub/responses {:api/responses {["search2" {:query "query term"}] :result}} [:api/responses])]
|
||||
(is (= :result (sub/response-for responses [:api/response-for "search2" {:query "query term"}])))
|
||||
(is (nil? (sub/response-for responses [:api/response-for "search2" {:query "another query term"}]))))))
|
||||
|
||||
(deftest endpoint-keywordification
|
||||
(testing "Should strip prefixes"
|
||||
|
|
@ -18,18 +18,36 @@
|
|||
(is (= :album-list (sub/endpoint->kw "getAlbumList2")))
|
||||
(is (= :search (sub/endpoint->kw "search3")))))
|
||||
|
||||
(def 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"}})
|
||||
|
||||
(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"}]}
|
||||
(let [current-route-events [[:api/request "getAlbumList2" {:type "recent", :size 18}]
|
||||
[:event/should-be-ignored]
|
||||
[:api/request "getArtistInfo" {:id "128"}]]]
|
||||
(is (= {:album-list (get responses ["getAlbumList2" {:type "recent" :size 18}])
|
||||
:artist-info (get responses ["getArtistInfo" {:id "128"}])}
|
||||
(sub/current-route-data [responses current-route-events]
|
||||
[:api/current-route-data]))))))
|
||||
|
||||
["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]))))))
|
||||
(deftest content-pending
|
||||
(testing "Should indicate if there are outstanding requests for the current route"
|
||||
(let [current-route-events [[:api/request "getAlbumList2" {:type "recent", :size 18}]
|
||||
[:event/should-be-ignored]
|
||||
[:api/request "getArtistInfo" {:id "128"}]]
|
||||
done responses
|
||||
in-progress (assoc-in responses
|
||||
[["getAlbumList2" {:type "recent" :size 18}] :api/is-loading?]
|
||||
true)]
|
||||
(is (true? (-> (sub/current-route-data [in-progress current-route-events]
|
||||
[:api/current-route-data])
|
||||
(sub/content-pending? [:api/content-pending?]))))
|
||||
(is (not (true? (-> (sub/current-route-data [done current-route-events]
|
||||
[:api/current-route-data])
|
||||
(sub/content-pending? [:api/content-pending?]))))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue