aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-auth-tests.el
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-11 23:54:33 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-12 18:11:48 -0400
commit24e038facf1a17d4996a9bca400aa6fe5ebf310b (patch)
tree8b832d868862f2ad216b3736037b6207ed51b513 /test/mastodon-auth-tests.el
parent82cf1d7faa31c654a2984e9d96b4e8e033694cf6 (diff)
Add store-client-id-and-secret test
Add `mastodon-auth--token-file' function Add test for `mastodon-auth--token-file'
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")))))