-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhowdoyou-test.el
58 lines (52 loc) · 2.59 KB
/
howdoyou-test.el
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
;;; howdoyou-test.el --- Tests for howdoyou
(ert-deftest test/links-from-google-search ()
"Should be able to show links"
(dolist (google-file '("google.0.html" "google.1.html" "google.2.html"))
(let* ((dom (make-dom-from-file google-file))
(result (howdoyou--extract-links-from-google dom)))
(message "%s" result)
(should (listp result)))))
;; (ert-deftest test/links-from-google-bot-search ()
;; "Should be able to show links"
;; (let* ((dom (make-dom-from-file "google2.html"))
;; (result (howdoyou--extract-links-from-google dom)) )
;; (message "%s" result)
;; (should (listp result))))
(ert-deftest-async test/promise-dom (done)
(promise-done
(promise-chain
(howdoyou--promise-dom "https://www.google.com")
(then (lambda (result)
(should (listp result))
;; (message "%s" result)
;; (error "error test")
(funcall done)))
(promise-catch done))))
;; (promise-catch (lambda (e) (funcall done e))))))
(ert-deftest-async test/promise-curl-dom (done)
(promise-done
(promise-chain
(howdoyou--curl-promise-dom "https://www.google.com")
(then (lambda (result)
(should (listp result))
;; (message "%s" result)
(funcall done)))
(promise-catch done))))
(ert-deftest-async test/howdoyou-read-so-link (done)
(promise-done
(promise-chain
(howdoyou-read-so-link "https://stackoverflow.com/questions/8425102/how-do-i-load-my-script-into-the-node-js-repl")
(then (lambda (result)
(should (buffer-live-p (get-buffer "*How Do You*")))
(funcall done)))
(promise-catch done))))
(ert-deftest-async test/promise-parsing (done)
(promise-done
(promise-chain
(howdoyou--promise-dom "https://stackoverflow.com/questions/586735/how-can-i-check-if-a-current-buffer-exists-in-emacs")
(then #'howdoyou--promise-so-answer)
(then (lambda (result)
(should (listp result))
(funcall done)))
(promise-catch done))))
;;; howdoyou-test.el ends here