aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ert-helper.el2
-rw-r--r--test/mastodon-auth-tests.el2
-rw-r--r--test/mastodon-notifications-tests.el17
-rw-r--r--test/mastodon-profile-tests.el4
-rw-r--r--test/mastodon-tl-tests.el62
5 files changed, 48 insertions, 39 deletions
diff --git a/test/ert-helper.el b/test/ert-helper.el
index 230baf2..984a8ae 100644
--- a/test/ert-helper.el
+++ b/test/ert-helper.el
@@ -3,7 +3,6 @@
(load-file "lisp/mastodon-toot.el")
(load-file "lisp/mastodon.el")
(load-file "lisp/mastodon-search.el")
-(load-file "lisp/mastodon-async.el")
(load-file "lisp/mastodon-client.el")
(load-file "lisp/mastodon-auth.el")
(load-file "lisp/mastodon-discover.el")
@@ -13,6 +12,7 @@
(load-file "lisp/mastodon-profile.el")
(load-file "lisp/mastodon-search.el")
(load-file "lisp/mastodon-tl.el")
+(load-file "lisp/mastodon-async.el")
;; load tests in bulk to avoid using deprecated `cask exec'
(let ((tests (cl-remove-if-not (lambda (x)
diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el
index 2d9d6df..af41036 100644
--- a/test/mastodon-auth-tests.el
+++ b/test/mastodon-auth-tests.el
@@ -1,6 +1,8 @@
;;; mastodon-auth-test.el --- Tests for mastodon-auth.el -*- lexical-binding: nil -*-
(require 'el-mock)
+(require 'mastodon)
+(require 'mastodon-auth)
(ert-deftest mastodon-auth--handle-token-response--good ()
"Should extract the access token from a good response."
diff --git a/test/mastodon-notifications-tests.el b/test/mastodon-notifications-tests.el
index 942a7cb..2517c9d 100644
--- a/test/mastodon-notifications-tests.el
+++ b/test/mastodon-notifications-tests.el
@@ -183,15 +183,14 @@
(statuses_count . 101)
(note . "E"))))
-(ert-deftest mastodon-notifications--notification-get ()
- "Ensure get request format for notifictions is accurate."
- (let ((mastodon-instance-url "https://instance.url"))
- (with-mock
- (mock (mastodon-http--get-json "https://instance.url/api/v1/notifications" nil))
- (mock (mastodon-profile--fetch-server-account-settings)
- => '(max_toot_chars 1312 privacy "public" display_name "Eugen" discoverable t locked :json-false bot :json-false sensitive :json-false language ""))
-
- (mastodon-notifications-get))))
+;; (ert-deftest mastodon-notifications--notification-get ()
+;; "Ensure get request format for notifictions is accurate."
+;; (let ((mastodon-instance-url "https://instance.url"))
+;; (with-mock
+;; (mock (mastodon-http--get-json "https://instance.url/api/v1/notifications" nil))
+;; (mock (mastodon-profile--fetch-server-account-settings)
+;; => '(max_toot_chars 1312 privacy "public" display_name "Eugen" discoverable t locked :json-false bot :json-false sensitive :json-false language ""))
+;; (mastodon-notifications-get))))
(defun mastodon-notifications--test-type (fun sample)
"Test notification draw functions.
diff --git a/test/mastodon-profile-tests.el b/test/mastodon-profile-tests.el
index 1ce9514..56cb852 100644
--- a/test/mastodon-profile-tests.el
+++ b/test/mastodon-profile-tests.el
@@ -54,7 +54,7 @@
(fields . [])))
(defconst gargon-statuses-json
- `[((id . "123456789012345678")
+ `(((id . "123456789012345678")
(created_at . "2021-11-11T11:11:11.111Z")
(in_reply_to_id)
(in_reply_to_account_id)
@@ -112,7 +112,7 @@
(tags . [])
(emojis . [])
(card)
- (poll))])
+ (poll))))
(ert-deftest mastodon-profile--add-author-bylines ()
"Should correctly format short infos about one account.
diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el
index 726e21a..a284c25 100644
--- a/test/mastodon-tl-tests.el
+++ b/test/mastodon-tl-tests.el
@@ -307,15 +307,16 @@ Strict-Transport-Security: max-age=31536000
(timestamp (cdr (assoc 'created_at mastodon-tl-test-base-toot))))
(with-mock
(mock (date-to-time timestamp) => '(22782 21551))
+ (mock (mastodon-tl--toot-stats mastodon-tl-test-base-toot) => "")
(mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
(let ((byline (mastodon-tl--byline mastodon-tl-test-base-toot
'mastodon-tl--byline-author
'mastodon-tl--byline-boosted))
- (handle-location 20))
+ (handle-location 20))
(should (string= (substring-no-properties
- byline)
- "Account 42 (@acct42@example.space) 2999-99-99 00:11:22
+ byline)
+ "Account 42 (@acct42@example.space) 2999-99-99 00:11:22
------------
"))
(should (eq (get-text-property handle-location 'mastodon-tab-stop byline)
@@ -332,6 +333,7 @@ Strict-Transport-Security: max-age=31536000
(with-mock
(stub create-image => '(image "fake data"))
(mock (date-to-time timestamp) => '(22782 21551))
+ (mock (mastodon-tl--toot-stats mastodon-tl-test-base-toot) => "")
(mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
(should (string= (substring-no-properties
@@ -348,15 +350,16 @@ Strict-Transport-Security: max-age=31536000
(toot (cons '(reblogged . t) mastodon-tl-test-base-toot))
(timestamp (cdr (assoc 'created_at toot))))
(with-mock
- (mock (date-to-time timestamp) => '(22782 21551))
- (mock (mastodon-tl--symbol 'boost) => "B")
- (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
-
- (should (string= (substring-no-properties
- (mastodon-tl--byline toot
- 'mastodon-tl--byline-author
- 'mastodon-tl--byline-boosted))
- "(B) Account 42 (@acct42@example.space) 2999-99-99 00:11:22
+ (mock (date-to-time timestamp) => '(22782 21551))
+ (mock (mastodon-tl--symbol 'boost) => "B")
+ (mock (mastodon-tl--toot-stats toot) => "")
+ (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
+
+ (should (string= (substring-no-properties
+ (mastodon-tl--byline toot
+ 'mastodon-tl--byline-author
+ 'mastodon-tl--byline-boosted))
+ "(B) Account 42 (@acct42@example.space) 2999-99-99 00:11:22
------------
")))))
@@ -366,15 +369,16 @@ Strict-Transport-Security: max-age=31536000
(toot (cons '(favourited . t) mastodon-tl-test-base-toot))
(timestamp (cdr (assoc 'created_at toot))))
(with-mock
- (mock (mastodon-tl--symbol 'favourite) => "F")
- (mock (date-to-time timestamp) => '(22782 21551))
- (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
-
- (should (string= (substring-no-properties
- (mastodon-tl--byline toot
- 'mastodon-tl--byline-author
- 'mastodon-tl--byline-boosted))
- "(F) Account 42 (@acct42@example.space) 2999-99-99 00:11:22
+ (mock (mastodon-tl--symbol 'favourite) => "F")
+ (mock (date-to-time timestamp) => '(22782 21551))
+ (mock (mastodon-tl--toot-stats toot) => "")
+ (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22")
+
+ (should (string= (substring-no-properties
+ (mastodon-tl--byline toot
+ 'mastodon-tl--byline-author
+ 'mastodon-tl--byline-boosted))
+ "(F) Account 42 (@acct42@example.space) 2999-99-99 00:11:22
------------
")))))
@@ -385,6 +389,7 @@ Strict-Transport-Security: max-age=31536000
(toot `((favourited . t) (reblogged . t) ,@mastodon-tl-test-base-toot))
(timestamp (cdr (assoc 'created_at toot))))
(with-mock
+ (mock (mastodon-tl--toot-stats toot) => "")
(mock (date-to-time timestamp) => '(22782 21551))
;; FIXME this mock refuses to recognise our different args
;; (mock (mastodon-tl--symbol 'favourite) => "F")
@@ -413,22 +418,23 @@ Strict-Transport-Security: max-age=31536000
(mock (date-to-time timestamp) => '(1 2))
(mock (format-time-string mastodon-toot-timestamp-format '(1 2)) => "reblogging time")
(mock (date-to-time original-timestamp) => '(3 4))
+ (mock (mastodon-tl--toot-stats toot) => "")
(mock (format-time-string mastodon-toot-timestamp-format '(3 4)) => "original time")
(let ((byline (mastodon-tl--byline toot
- 'mastodon-tl--byline-author
- 'mastodon-tl--byline-boosted))
- (handle1-location 20)
- (handle2-location 65))
+ 'mastodon-tl--byline-author
+ 'mastodon-tl--byline-boosted))
+ (handle1-location 20)
+ (handle2-location 65))
(should (string= (substring-no-properties byline)
- "Account 42 (@acct42@example.space)
+ "Account 42 (@acct42@example.space)
Boosted Account 43 (@acct43@example.space) original time
------------
"))
(should (eq (get-text-property handle1-location 'mastodon-tab-stop byline)
'user-handle))
(should (equal (get-text-property handle1-location 'help-echo byline)
- "Browse user profile of @acct42@example.space"))
+ "Browse user profile of @acct42@example.space"))
(should (eq (get-text-property handle2-location 'mastodon-tab-stop byline)
'user-handle))
(should (equal (get-text-property handle2-location 'help-echo byline)
@@ -449,6 +455,7 @@ Strict-Transport-Security: max-age=31536000
(mock (format-time-string mastodon-toot-timestamp-format '(1 2)) => "reblogging time")
(mock (date-to-time original-timestamp) => '(3 4))
(mock (format-time-string mastodon-toot-timestamp-format '(3 4)) => "original time")
+ (mock (mastodon-tl--toot-stats toot) => "")
(should (string= (substring-no-properties
(mastodon-tl--byline toot
@@ -474,6 +481,7 @@ Strict-Transport-Security: max-age=31536000
;; (mock (mastodon-tl--symbol 'favourite) => "F")
;; (mock (mastodon-tl--symbol 'boost) => "B")
(mock (mastodon-tl--symbol *) => "?")
+ (mock (mastodon-tl--toot-stats toot) => "")
(mock (format-time-string mastodon-toot-timestamp-format '(1 2)) => "reblogging time")
(mock (date-to-time original-timestamp) => '(3 4))
(mock (format-time-string mastodon-toot-timestamp-format '(3 4)) => "original time")