aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-11 13:26:58 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-12 18:11:48 -0400
commit88e7f432c089a31aea0694173fd16707ac01b931 (patch)
tree1e43766af2486abb73ff062cb9960f2d5aed032e
parentf091a811d0a6e13b22542caf08bd23833456f2c8 (diff)
Add mastodon--register-and-return-client-app test
Refactor tests to check plist return value
-rw-r--r--test/mastodon-auth-tests.el41
1 files changed, 27 insertions, 14 deletions
diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el
index 160a09e..371abcc 100644
--- a/test/mastodon-auth-tests.el
+++ b/test/mastodon-auth-tests.el
@@ -13,19 +13,32 @@
(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)))))
+ "Should POST client data to /apps endpoint and return client plist."
+ (let ((app-plist '("id" "id-val" "secret" "secret-val")))
+ (with-mock
+ (mock (mastodon--api-for "apps") => "https://instance/api/v1/apps")
+ (mock (mastodon--register-client-app-triage "status") => app-plist)
+ (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")))
+ => (funcall 'mastodon--register-client-app-triage "status"))
+ (should (eq app-plist (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")))))
+ "Should wrap `mastodon--http-response-triage' call and return client plist."
+ (let ((app-plist '("id" "id-val" "secret" "secret-val")))
+ (with-mock
+ (mock (mastodon-auth--registration-success) => app-plist)
+ (mock (mastodon--http-response-triage "status" 'mastodon-auth--registration-success)
+ => (funcall 'mastodon-auth--registration-success))
+ (should (eq app-plist (mastodon--register-client-app-triage "status"))))))
+
+(ert-deftest mastodon-auth:register-and-return-client-app ()
+ "Should return a plist of client_id and client_secret after registration."
+ (let ((app-plist '("id" "id-val" "secret" "secret-val")))
+ (with-mock
+ (mock (mastodon--register-client-app) => app-plist)
+ (should (equal app-plist (mastodon--register-and-return-client-app))))))