mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Add tests for auth process
This commit is contained in:
parent
ca8972f8c3
commit
ed060e55b6
5 changed files with 54 additions and 23 deletions
28
test/cljs/airsonic_ui/events_test.cljs
Normal file
28
test/cljs/airsonic_ui/events_test.cljs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(ns airsonic-ui.events-test
|
||||
(:require [cljs.test :refer [deftest testing is]]
|
||||
[clojure.string :as str]
|
||||
[airsonic-ui.events :as events]))
|
||||
|
||||
(enable-console-print!)
|
||||
|
||||
(deftest authentication
|
||||
(testing "Credential verification"
|
||||
(let [server "https://localhost"
|
||||
fx (events/authenticate {:db {}} [:_ "user" "pass" server])
|
||||
request (:http-xhrio fx)]
|
||||
(testing "uses correct server url"
|
||||
(is (str/starts-with? (:uri request) server))
|
||||
(is (str/includes? (:uri request) "/ping")))
|
||||
(testing "saves the given server location"
|
||||
(is (= server (get-in fx [:db :server]))))
|
||||
(testing "invokes correct success callback"
|
||||
(is (= ::events/credentials-verified (first (:on-success request)))))))
|
||||
(testing "On succesfull response"
|
||||
(let [fx (events/credentials-verified {:db {}} [:_ "user" "pass"])
|
||||
credentials {:u "user" :p "pass"}]
|
||||
(testing "credentials are sent to the router for access rights"
|
||||
(is (= credentials (:routes/set-credentials fx))))
|
||||
(testing "credentials are saved in the global state"
|
||||
(is (= credentials (get-in fx [:db :login]))))
|
||||
(testing "the login process is finalized"
|
||||
(is (= [::events/logged-in] (:dispatch fx)))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue