From 40a54819cfcba889a812c721d4cc0743ce5ae544 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Wed, 12 Apr 2017 12:04:03 -0400 Subject: Abstract success lambda to its own function and test Add `mastodon-auth--get-token-success' Add test for `mastodon-auth--get-token-success' Add test for `mastodon--get-access-token-triage' --- test/mastodon-auth-tests.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/mastodon-auth-tests.el') diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 95ba597..4560e27 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -87,3 +87,17 @@ (mock (mastodon-auth--token-file) => "fixture/empty.plstore") (mock (mastodon--store-client-id-and-secret)) (mastodon--client-app))) + +(ert-deftest mastodon-auth:get-token-success () + "Should return access token from `url-retrieve' response JSON." + (let ((hash (make-hash-table :test 'equal))) + (puthash "access_token" "token-value" hash) + (with-mock + (mock (mastodon--json-hash-table) => hash) + (should (string= (mastodon-auth--get-token-success) "token-value"))))) + +(ert-deftest mastodon-auth:get-access-token-triage () + "Should wrap `mastodon--http-response-triage'." + (with-mock + (mock (mastodon--http-response-triage "status" 'mastodon-auth--get-token-success)) + (mastodon--get-access-token-triage "status"))) -- cgit v1.2.3