aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-auth-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/mastodon-auth-tests.el')
-rw-r--r--test/mastodon-auth-tests.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el
index 371abcc..0012e3e 100644
--- a/test/mastodon-auth-tests.el
+++ b/test/mastodon-auth-tests.el
@@ -1,6 +1,13 @@
(require 'el-mock)
+
+(load-file "../lisp/mastodon.el")
+(load-file "../lisp/mastodon-http.el")
(load-file "../lisp/mastodon-auth.el")
+(ert-deftest mastodon-auth:token-file ()
+ "Should return `mastodon-token-file' value."
+ (should (string= (mastodon-auth--token-file) "~/.emacs.d/mastodon.plstore")))
+
(ert-deftest mastodon-auth:registration-success ()
"Should set `mastodon--client-app-plist' on succesful registration."
(let ((hash (make-hash-table :test 'equal))
@@ -42,3 +49,20 @@
(with-mock
(mock (mastodon--register-client-app) => app-plist)
(should (equal app-plist (mastodon--register-and-return-client-app))))))
+
+(defun helper:read-plstore (file key)
+ (let* ((plstore (plstore-open file))
+ (masto (delete "mastodon" (plstore-get plstore "mastodon"))))
+ (progn
+ (plstore-close plstore)
+ (plist-get masto key))))
+
+(ert-deftest mastodon-auth:store-client-id-and-secret ()
+ "Should create plstore from client plist. Should return plist."
+ (let ((app-plist '(:client_id "id-val" :client_secret "secret-val")))
+ (with-mock
+ (mock (mastodon--register-and-return-client-app) => app-plist)
+ (mock (mastodon-auth--token-file) => "stubfile.plstore")
+ (should (eq app-plist (mastodon--store-client-id-and-secret)))
+ (should (string= (helper:read-plstore (mastodon-auth--token-file) :client_id) "id-val"))
+ (should (string= (helper:read-plstore (mastodon-auth--token-file) :client_secret) "secret-val")))))