Added tests
This commit is contained in:
parent
49dbc4599e
commit
60e14a8403
3 changed files with 38 additions and 2 deletions
|
@ -5,5 +5,4 @@
|
||||||
(category web)
|
(category web)
|
||||||
(license "BSD")
|
(license "BSD")
|
||||||
(depends awful spiffy intarweb)
|
(depends awful spiffy intarweb)
|
||||||
;(test-depends test)
|
(test-depends test server-test uri-common http-client))
|
||||||
)
|
|
||||||
|
|
20
tests/client.scm
Normal file
20
tests/client.scm
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
(use awful-sse)
|
||||||
|
|
||||||
|
(define (sse-proc)
|
||||||
|
(send-sse-data "sse"))
|
||||||
|
|
||||||
|
(define-page/sse "/client"
|
||||||
|
(lambda ()
|
||||||
|
;; Unnecessary as our client it not a browser
|
||||||
|
;; (add-javascript
|
||||||
|
;; "var source = new EventSource('/sse');
|
||||||
|
;; source.onmessage = function (event) {
|
||||||
|
;; display = document.getElementById('display');
|
||||||
|
;; display.innerHTML = event.data;
|
||||||
|
;; };")
|
||||||
|
|
||||||
|
"foo") ; page contents won't be accessed anyway
|
||||||
|
|
||||||
|
"/sse"
|
||||||
|
sse-proc
|
||||||
|
no-template: #t)
|
17
tests/run.scm
Normal file
17
tests/run.scm
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
(use awful http-client intarweb uri-common server-test test)
|
||||||
|
|
||||||
|
(awful-apps (list "client.scm"))
|
||||||
|
|
||||||
|
(with-test-server
|
||||||
|
(lambda ()
|
||||||
|
(awful-start
|
||||||
|
(lambda ()
|
||||||
|
(load-apps (awful-apps)))))
|
||||||
|
(lambda ()
|
||||||
|
(test "data: sse\n\n"
|
||||||
|
(with-input-from-request
|
||||||
|
(make-request
|
||||||
|
uri: (uri-reference "http://localhost:8080/sse")
|
||||||
|
headers: (headers '((accept text/event-stream))))
|
||||||
|
#f
|
||||||
|
read-string))))
|
Loading…
Reference in a new issue