mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Merge feature/search
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
This commit is contained in:
parent
d26decb2ff
commit
7653af5dd1
22 changed files with 236 additions and 49 deletions
|
|
@ -1,7 +1,7 @@
|
|||
(ns airsonic-ui.api.helpers-test
|
||||
(:require [cljs.test :refer [deftest testing is]]
|
||||
[clojure.string :as str]
|
||||
[airsonic-ui.fixtures :refer [responses]]
|
||||
[airsonic-ui.fixtures :as fixtures :refer [responses]]
|
||||
[airsonic-ui.api.helpers :as api]))
|
||||
|
||||
(defn- url
|
||||
|
|
@ -20,6 +20,12 @@
|
|||
(is (string? (re-find #"f=json" (fixtures :default-url))))
|
||||
(is (string? (re-find #"v=1\.15\.0" (fixtures :default-url))))))
|
||||
|
||||
(deftest parameter-encoding
|
||||
(testing "Should escape url parameters"
|
||||
(let [query "äöüß"
|
||||
encoded-str (js/encodeURIComponent query)]
|
||||
(is (str/includes? (api/url "http://localhost" "search3" {:query query}) encoded-str)))))
|
||||
|
||||
(deftest song-urls
|
||||
(testing "Should construct the url based on a song's id"
|
||||
(let [song {:id 1234}]
|
||||
|
|
@ -46,7 +52,7 @@
|
|||
(try
|
||||
(api/unwrap-response error-response)
|
||||
(catch ExceptionInfo e
|
||||
(= (:error error-response) (ex-data e)))))))
|
||||
(is (= (get-in error-response [:subsonic-response :error]) (ex-data e))))))))
|
||||
|
||||
(deftest error-recognition
|
||||
(testing "Should detect error responses"
|
||||
|
|
@ -55,3 +61,13 @@
|
|||
(testing "Should pass on good responses"
|
||||
(is (false? (api/is-error? (:ok responses))))
|
||||
(is (false? (api/is-error? (:auth-success responses))))))
|
||||
|
||||
(deftest content-type
|
||||
(testing "Should detect whether the data we look at represents a song"
|
||||
(is (= :content-type/song (api/content-type fixtures/song))))
|
||||
(testing "Should detect whether the data we look at represents an artist"
|
||||
(is (= :content-type/artist (api/content-type fixtures/artist)))
|
||||
(is (= :content-type/artist (api/content-type (dissoc fixtures/artist :coverArt)))))
|
||||
(testing "Should detect whether the data we look at represents an album"
|
||||
(is (= :content-type/album (api/content-type fixtures/album)))
|
||||
(is (= :content-type/album (api/content-type (dissoc fixtures/album :coverArt))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue