mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Add tests on notification widget and fix bugs
This commit is contained in:
parent
cec308d90d
commit
0d051b0102
2 changed files with 34 additions and 4 deletions
|
@ -41,8 +41,8 @@
|
|||
;; Note: can't put this below of `ein:notification-setup'...
|
||||
|
||||
(defclass ein:notification-status ()
|
||||
((status :initarg :status :initform nil :type symbol)
|
||||
(message :initarg :message :initform "" :type string)
|
||||
((status :initarg :status :initform nil)
|
||||
(message :initarg :message :initform nil)
|
||||
(s2m :initarg :s2m))
|
||||
"Hold status and it's string representation (message).")
|
||||
|
||||
|
@ -70,12 +70,12 @@
|
|||
:type ein:notification-status))
|
||||
"Notification widget for Notebook.")
|
||||
|
||||
(defmethod ein:notification-status-set ((ns (ein:notification-status)) status)
|
||||
(defmethod ein:notification-status-set ((ns ein:notification-status) status)
|
||||
(let* ((message (cdr (assoc status (oref ns :s2m)))))
|
||||
(oset ns :status status)
|
||||
(oset ns :message message)))
|
||||
|
||||
(defmethod ein:notification-bind-events ((notification (ein:notification))
|
||||
(defmethod ein:notification-bind-events ((notification ein:notification)
|
||||
events)
|
||||
"Bind a callback to events of the event handler EVENTS which
|
||||
just set the status \(= event-type):
|
||||
|
|
30
tests/test-ein-notification.el
Normal file
30
tests/test-ein-notification.el
Normal file
|
@ -0,0 +1,30 @@
|
|||
(eval-when-compile (require 'cl))
|
||||
(require 'ert)
|
||||
|
||||
(require 'ein-notification)
|
||||
|
||||
(ert-deftest ein-header-line-kernel-status-busy ()
|
||||
(let* ((ein:@notification (ein:notification "NotificationTest"))
|
||||
(kernel (oref ein:@notification :kernel)))
|
||||
(ein:notification-status-set kernel
|
||||
'(status_busy . Kernel))
|
||||
(should (equal (ein:header-line) "IP[y]: Kernel is busy..."))))
|
||||
|
||||
(ert-deftest ein-header-line-notebook-status-busy ()
|
||||
(let* ((ein:@notification (ein:notification "NotificationTest"))
|
||||
(notebook (oref ein:@notification :notebook)))
|
||||
(ein:notification-status-set notebook
|
||||
'(notebook_saved . Notebook))
|
||||
(should (equal (ein:header-line) "IP[y]: Notebook is saved"))))
|
||||
|
||||
(ert-deftest ein-header-line-notebook-complex ()
|
||||
(let* ((ein:@notification (ein:notification "NotificationTest"))
|
||||
(kernel (oref ein:@notification :kernel))
|
||||
(notebook (oref ein:@notification :notebook)))
|
||||
(ein:notification-status-set kernel
|
||||
'(status_dead . Kernel))
|
||||
(ein:notification-status-set notebook
|
||||
'(notebook_saving . Notebook))
|
||||
(should (equal
|
||||
(ein:header-line)
|
||||
"IP[y]: Saving Notebook... | Kernel is dead. Need restart."))))
|
Loading…
Add table
Reference in a new issue