aboutsummaryrefslogtreecommitdiff
path: root/test/tests.el
blob: be1552ba60ae6c397c9d2280ac2f4985712043ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

;;; SX Settings
(defun -sx--nuke ()
  (interactive)
  (mapatoms
   (lambda (symbol)
     (if (string-prefix-p "sx-" (symbol-name symbol))
         (unintern symbol)))))

(setq
 sx-initialized t
 sx-request-remaining-api-requests-message-threshold 50000
 debug-on-error t
 url-show-status nil
 user-emacs-directory "."
 sx-test-base-dir (file-name-directory (or load-file-name "./")))


;;; Test Data
(defvar sx-test-data-dir
  (expand-file-name "data-samples/" sx-test-base-dir))

(defun sx-test-sample-data (method &optional directory)
  (let ((file (concat (when directory (concat directory "/"))
                      sx-test-data-dir
                      method ".el")))
    (when (file-exists-p file)
      (with-temp-buffer
        (insert-file-contents file)
        (read (buffer-string))))))

(setq
 sx-test-data-questions
 (sx-test-sample-data "questions")
 sx-test-data-sites
 (sx-test-sample-data "sites"))


;;; General Settings
(setq
 package-user-dir (expand-file-name
                   (format "../../.cask/%s/elpa" emacs-version)
                   sx-test-data-dir))

(package-initialize)

(require 'sx-load)

(defun sx-load-test (test)
  (load-file
   (format "%s/test-%s.el"
           sx-test-base-dir
           (symbol-name test))))

(setq sx-test-enable-messages nil)

(defun sx-test-message (message &rest args)
  (when sx-test-enable-messages
    (apply #'message message args)))

(mapc #'sx-load-test
  '(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))))