aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-auth-tests.el
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-11 12:56:23 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-12 18:11:48 -0400
commitf091a811d0a6e13b22542caf08bd23833456f2c8 (patch)
tree1310bb2ec2c935e9dfcfd38214a8284486cf1bb4 /test/mastodon-auth-tests.el
parent9831a8fdae04a4b23b4f4d271d5806131c90a528 (diff)
Add mastodon-auth--register-client-app test
Add mastodon-auth--register-client-app-triage test
Diffstat (limited to 'test/mastodon-auth-tests.el')
-rw-r--r--test/mastodon-auth-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el
index 0963e95..160a09e 100644
--- a/test/mastodon-auth-tests.el
+++ b/test/mastodon-auth-tests.el
@@ -2,6 +2,7 @@
(load-file "../lisp/mastodon-auth.el")
(ert-deftest mastodon-auth:registration-success ()
+ "Should set `mastodon--client-app-plist' on succesful registration."
(let ((hash (make-hash-table :test 'equal))
(client-plist '(:client_id "client-id" :client_secret "client-secret")))
(puthash "client_id" "client-id" hash)
@@ -10,3 +11,21 @@
(stub mastodon--json-hash-table => hash)
(mastodon-auth--registration-success)
(should (equal client-plist mastodon--client-app-plist)))))
+
+(ert-deftest mastodon-auth:register-client-app ()
+ "Should POST client data to /apps endpoint."
+ (with-mock
+ (mock (mastodon--api-for "apps") => "https://instance/api/v1/apps")
+ (mock (mastodon--http-post "https://instance/api/v1/apps"
+ 'mastodon--register-client-app-triage
+ '(("client_name" . "mastodon.el")
+ ("redirect_uris" . "urn:ietf:wg:oauth:2.0:oob")
+ ("scopes" . "read write follow")
+ ("website" . "https://github.com/jdenen/mastodon.el"))))
+ (should (eq nil (mastodon--register-client-app)))))
+
+(ert-deftest mastodon-auth:register-client-app-triage ()
+ "Should wrap `mastodon--http-response-triage' call."
+ (with-mock
+ (mock (mastodon--http-response-triage "status" 'mastodon-auth--registration-success))
+ (should (eq nil (mastodon--register-client-app-triage "status")))))