diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-12 09:41:17 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-12 18:11:48 -0400 |
commit | 59390fba8c795973069064f4216550f4e088a98f (patch) | |
tree | 6f445ae5d7d2a2c3e3abb4d1e334427b338187ec /test | |
parent | 24e038facf1a17d4996a9bca400aa6fe5ebf310b (diff) |
Add mastodon--client-app tests
Diffstat (limited to 'test')
-rw-r--r-- | test/fixture/client.plstore | 2 | ||||
-rw-r--r-- | test/fixture/empty.plstore | 2 | ||||
-rw-r--r-- | test/mastodon-auth-tests.el | 21 |
3 files changed, 25 insertions, 0 deletions
diff --git a/test/fixture/client.plstore b/test/fixture/client.plstore new file mode 100644 index 0000000..3514ed9 --- /dev/null +++ b/test/fixture/client.plstore @@ -0,0 +1,2 @@ +;;; public entries -*- mode: plstore -*- +(("mastodon" :client_id "id" :client_secret "secret")) diff --git a/test/fixture/empty.plstore b/test/fixture/empty.plstore new file mode 100644 index 0000000..4685e78 --- /dev/null +++ b/test/fixture/empty.plstore @@ -0,0 +1,2 @@ +;;; public entries -*- mode: plstore -*- +(("ignore" :client_id "id" :client_secret "secret")) diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 0012e3e..95ba597 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -66,3 +66,24 @@ (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"))))) + +(ert-deftest mastodon-auth:client-app:memoized () + "Should return `mastodon--client-app-plist' if it has a :client_secret." + (with-mock + (mock (plist-get mastodon--client-app-plist :client_secret) => t) + (should (eq (mastodon--client-app) mastodon--client-app-plist)))) + +(ert-deftest mastodon-auth:client-app:stored () + "Should retrieve from `mastodon-token-file' if not memoized." + (with-mock + (stub plist-get) + (mock (mastodon-auth--token-file) => "fixture/client.plstore") + (should (equal (mastodon--client-app) '(:client_id "id" :client_secret "secret"))))) + +(ert-deftest mastodon-auth:client-app:generated () + "Should generate `mastodon--client-app-plist' if not memoized or stored." + (with-mock + (stub plist-get) + (mock (mastodon-auth--token-file) => "fixture/empty.plstore") + (mock (mastodon--store-client-id-and-secret)) + (mastodon--client-app))) |