-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathurl-el-integration-tests.el
116 lines (103 loc) · 4.27 KB
/
url-el-integration-tests.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(require 'ert)
(add-to-list 'load-path ".")
(load "org-cliplink.el")
(custom-set-variables
'(org-cliplink-transport-implementation (quote url-el))
'(network-security-level (quote low)))
(ert-deftest org-cliplink-without-title--http ()
(let ((url "http://127.0.0.1:8001/without-title.html")
(expected-outcome "[[http://127.0.0.1:8001/without-title.html]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-long-title-with-custom-transformer--http ()
(let ((url "http://127.0.0.1:8001/long-title.html")
(expected-outcome "[[http://127.0.0.1:8001/long-title.html][long title]]")
(timeout 1)
(custom-org-cliplink
(lambda ()
(org-cliplink-insert-transformed-title
(org-cliplink-clipboard-content)
(lambda (url title)
(org-cliplink-org-mode-link-transformer
url
(replace-regexp-in-string "\\(very \\)+\\([[:alpha:][:space:]]+\\)" "\\2" title)))))))
(with-temp-buffer
(kill-new url)
(funcall custom-org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-retrieve-long-title-synchronously--http ()
(let ((url "http://127.0.0.1:8001/long-title.html")
(expected-outcome "very very very very very very very very very very very very very very very ve..."))
(should (equal (org-cliplink-retrieve-title-synchronously url)
expected-outcome))))
(ert-deftest org-cliplink-simple-title--http ()
(let ((url "http://127.0.0.1:8001/http.html")
(expected-outcome "[[http://127.0.0.1:8001/http.html][Hello World]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-escape-title--http ()
(let ((url "http://127.0.0.1:8001/html4-escaping.html")
(expected-outcome "[[http://127.0.0.1:8001/html4-escaping.html][&{Hello} '{World} α ]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--https ()
(let ((url "https://127.0.0.1:4443/http.html")
(expected-outcome "[[https://127.0.0.1:4443/http.html][Hello World]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--gziped-http ()
(let ((url "http://127.0.0.1:8002/http.html")
(expected-outcome "[[http://127.0.0.1:8002/http.html][Hello World]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-escape-title--gziped-https ()
(let ((url "https://127.0.0.1:4444/html4-escaping.html")
(expected-outcome "[[https://127.0.0.1:4444/html4-escaping.html][&{Hello} '{World} α ]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--http-with-basic-auth ()
(let ((url "http://127.0.0.1:8003/http.html")
(expected-outcome "[[http://127.0.0.1:8003/http.html][Hello World]]")
(timeout 5)
(org-cliplink-secrets-path "./test-data/secrets/org-cliplink-basic-auth-it.el"))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--https-with-basic-auth ()
(let ((url "https://127.0.0.1:4445/http.html")
(expected-outcome "[[https://127.0.0.1:4445/http.html][Hello World]]")
(timeout 5)
(org-cliplink-secrets-path "./test-data/secrets/org-cliplink-basic-auth-it.el"))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-run-tests-batch-and-exit)