From e20f074de9927451a8f3f496632a39e4937b78b8 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Wed, 12 Apr 2017 13:55:23 -0400 Subject: Add tests for `mastodon--access-token' --- test/mastodon-auth-tests.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 6e8b10c..7c2bb0c 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -103,7 +103,7 @@ (mastodon--get-access-token-triage "status"))) (ert-deftest mastodon-auth:get-access-token () - "Should POST auth data to retreive access token." + "Should POST auth data to retrieve access token." (let ((client-app '(:client_id "id" :client_secret "secret"))) (with-mock (mock (mastodon-auth--user-and-passwd) => (cons "email" "password")) @@ -117,3 +117,17 @@ ("password" . "password") ("scope" . "read write follow")))) (mastodon--get-access-token)))) + +(ert-deftest mastodon-auth:access-token:memoized () + "Should return `mastodon--api-token-string' if set." + (with-mock + (mock (mastodon-auth--token) => "foobar") + (should (string= (mastodon--access-token) "foobar")))) + +(ert-deftest mastodon-auth:access-token:generated () + "Should generate `mastodon--api-token-string' if not memoized." + (with-mock + (mock (mastodon-auth--token) => nil) + (mock (mastodon--get-access-token) + => (mock (mastodon-auth--token) => "foobar")) + (should (string= (mastodon--access-token) "foobar")))) -- cgit v1.2.3