feat: add root-level minibuffer actions and update template
This commit is contained in:
+24
-18
@@ -106,29 +106,35 @@
|
||||
"spine-set-status signals error for unknown ID."
|
||||
(should-error (spine-set-status "nonexistent-id" "READING")))
|
||||
|
||||
(ert-deftest spine-edit-model-minibuffer-want ()
|
||||
"Selected WANT book has Mark reading and Add note actions."
|
||||
(spine-edit-test--cleanup)
|
||||
|
||||
(ert-deftest spine-edit-model-minibuffer-reading ()
|
||||
"Selected READING book has Mark read, Abandon, Add note actions."
|
||||
(spine-edit-test--cleanup)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(spine-edit-test--setup)
|
||||
(let* ((books (spine-books))
|
||||
(book (car books))
|
||||
(id (plist-get book :id))
|
||||
(model (spine-index-model books nil id))
|
||||
(groups (ht-get model "groups")))
|
||||
(cl-labels ((find-book-model (groups id)
|
||||
(cl-block nil
|
||||
(dolist (g groups)
|
||||
(dolist (b (ht-get g "books"))
|
||||
(when (string= (ht-get b "title") "Edit Test Book")
|
||||
(cl-return b)))))))
|
||||
(let ((bm (find-book-model groups id)))
|
||||
(should bm)
|
||||
(let ((mb (ht-get bm "minibuffer")))
|
||||
(should mb)
|
||||
(let ((actions (ht-get mb "actions")))
|
||||
(should (= (length actions) 2))
|
||||
(should (string= (ht-get (nth 0 actions) "label") "Mark reading"))
|
||||
(should (string= (ht-get (nth 1 actions) "label") "Add note"))))))))
|
||||
(id (plist-get book :id)))
|
||||
(spine-set-status id "READING")
|
||||
(let ((model (spine-index-model (spine-books) nil id)))
|
||||
(let ((mb (ht-get model "minibuffer")))
|
||||
(should mb)
|
||||
(let ((actions (ht-get mb "actions")))
|
||||
(should (= (length actions) 3))
|
||||
(should (string= (ht-get (nth 0 actions) "label") "Mark read"))
|
||||
(should (string= (ht-get (nth 1 actions) "label") "Abandon"))
|
||||
(should (string= (ht-get (nth 2 actions) "label") "Add note")))))))
|
||||
(spine-edit-test--cleanup)))
|
||||
|
||||
(ert-deftest spine-edit-model-minibuffer-nil-when-no-selection ()
|
||||
"No minibuffer when no book is selected."
|
||||
(spine-edit-test--cleanup)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(spine-edit-test--setup)
|
||||
(let ((model (spine-index-model (spine-books))))
|
||||
(should-not (ht-get model "minibuffer"))))
|
||||
(spine-edit-test--cleanup)))
|
||||
|
||||
Reference in New Issue
Block a user