mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Add user notifications
This commit is contained in:
parent
187f001414
commit
68a96bc398
9 changed files with 140 additions and 18 deletions
|
|
@ -43,3 +43,26 @@
|
|||
(testing "When there's no previous login data"
|
||||
(testing "remembering has no effect"
|
||||
(is (nil? (events/try-remember-user {} [:_]))))))
|
||||
|
||||
(defn- first-notification [db]
|
||||
(-> (:notifications db) vals first))
|
||||
|
||||
(deftest user-notifications
|
||||
(testing "Should be able to display a message with an assigned level"
|
||||
(is (= :error (:level (first-notification (events/show-notification {} [:_ :error "foo"])))))
|
||||
(is (= :info (:level (first-notification (events/show-notification {} [:_ :info "some other message"]))))))
|
||||
(testing "Should default to level :info"
|
||||
(is (= :info (:level (first-notification (events/show-notification {} [:_ "and another one"]))))))
|
||||
(testing "Should create a unique id for each message"
|
||||
(let [state (->
|
||||
{}
|
||||
(events/show-notification [:_ :info "Something something"])
|
||||
(events/show-notification [:_ :error "Something important"]))
|
||||
ids (keys (:notifications state))]
|
||||
(is (= (count ids) (count (set ids))))))
|
||||
(testing "Should remove a message, given it's id"
|
||||
(let [state (events/show-notification {} [:_ "This is a notification"])
|
||||
id (-> (:notifications state)
|
||||
keys
|
||||
first)]
|
||||
(is (empty? (:notifications (events/hide-notification state [:_ id])))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue