aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-auth-test.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-01 15:53:37 +0100
committerHolger Dürer <me@hdurer.net>2021-11-01 15:53:37 +0100
commite7c7da386c812f9452b072567e822077180f3dc5 (patch)
treecfd28454b3c54404381620a1e77e722b6d5e9740 /test/mastodon-auth-test.el
parentd7593a06912b7946d2fb318093ec7e27c64b3be7 (diff)
Fix tests.
These needed a bit of tender love and care to get back into passing state. - Move the auth tests to the `test` directory. No idea what it was doing in `lisp`. - Image tests are mostly broken because with later Emacsen we no longer need the `imagemagic` option on create-image. - Some method signatures have changed and mocking calls needed to follow suit.
Diffstat (limited to 'test/mastodon-auth-test.el')
-rw-r--r--test/mastodon-auth-test.el47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/mastodon-auth-test.el b/test/mastodon-auth-test.el
new file mode 100644
index 0000000..9a765b9
--- /dev/null
+++ b/test/mastodon-auth-test.el
@@ -0,0 +1,47 @@
+;;; mastodon-auth--test.el --- Tests for mastodon-auth -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Ian Eure
+
+;; Author: Ian Eure <ian@retrospec.tv>
+;; Version: 0.9.1
+;; Homepage: https://github.com/jdenen/mastodon.el
+;; Package-Requires: ((emacs "26.1"))
+
+;; This file is not part of GNU Emacs.
+
+;; This file is part of mastodon.el.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; mastodon-auth--test.el provides ERT tests for mastodon-auth.el
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest mastodon-auth--handle-token-response--good ()
+ (should (string= "foo" (mastodon-auth--handle-token-response '(:access_token "foo" :token_type "Bearer" :scope "read write follow" :created_at 0)))))
+
+(ert-deftest mastodon-auth--handle-token-response--unknown ()
+ :expected-result :failed
+ (mastodon-auth--handle-token-response '(:herp "derp")))
+
+(ert-deftest mastodon-auth--handle-token-response--failure ()
+ :expected-result :failed
+ (mastodon-auth--handle-token-response '(:error "invalid_grant" :error_description "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.")))
+
+(provide 'mastodon-auth--test)
+;;; mastodon-auth--test.el ends here