aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-question.el3
-rw-r--r--test/test-printing.el24
-rw-r--r--test/tests.el22
3 files changed, 47 insertions, 2 deletions
diff --git a/sx-question.el b/sx-question.el
index 1df4900..1fde1aa 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -148,7 +148,8 @@ See `sx-question--user-read-list'."
;; Question wasn't present.
(t
(sx-sorted-insert-skip-first
- q-cell site-cell (lambda (x y) (> (car x) (car y))))))))
+ q-cell site-cell
+ (lambda (x y) (> (or (car x) -1) (or (car y) -1))))))))
;; Save the results.
;; @TODO This causes a small lag on `j' and `k' as the list gets
;; large. Should we do this on a timer?
diff --git a/test/test-printing.el b/test/test-printing.el
index 7384829..bcc3dd9 100644
--- a/test/test-printing.el
+++ b/test/test-printing.el
@@ -27,6 +27,18 @@ after being run through `sx-question--tag-format'."
;;; Tests
+(ert-deftest time-since ()
+ (cl-letf (((symbol-function #'float-time)
+ (lambda () 1420148997.)))
+ (should
+ (string=
+ "67m"
+ (sx-time-since 1420145000.)))
+ (should
+ (string=
+ "12h"
+ (sx-time-since 1420105000.)))))
+
(ert-deftest question-list-tag ()
"Test `sx-question--tag-format'."
(should
@@ -134,6 +146,17 @@ after being run through `sx-question--tag-format'."
(should
(equal object '((answers . [something "answer"]))))))
+
+;;; question-mode
+(ert-deftest sx-display-question ()
+ ;; Check it doesn't error.
+ (sx-display-question (elt sx-test-data-questions 0))
+ ;; Check it does error.
+ (should-error
+ (sx-display-question sx-test-data-questions))
+ (should-error
+ (sx-display-question sx-test-data-questions nil 1)))
+
(ert-deftest sx-question-mode--fill-and-fontify ()
"Check complicated questions are filled correctly."
(should
@@ -190,3 +213,4 @@ if you used the Stack Exchange login method, you'd...
[1]: http://i.stack.imgur.com/ktFTs.png
[2]: http://i.stack.imgur.com/5l2AY.png
[3]: http://i.stack.imgur.com/22myl.png")))
+
diff --git a/test/tests.el b/test/tests.el
index ce42a9f..be1552b 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -59,4 +59,24 @@
(apply #'message message args)))
(mapc #'sx-load-test
- '(api macros printing util search))
+ '(api macros printing util search state))
+
+(ert-deftest user-entry-functions ()
+ "Ensures all entry functions are autoloaded."
+ (should
+ (cl-every
+ #'fboundp
+ '(sx-ask
+ sx-authenticate
+ sx-bug-report
+ sx-switchto-map
+ sx-tab-featured
+ sx-tab-frontpage
+ sx-tab-hot
+ sx-tab-month
+ sx-tab-newest
+ sx-tab-starred
+ sx-tab-topvoted
+ sx-tab-unanswered
+ sx-tab-week
+ sx-version))))