Added tests

This commit is contained in:
arthurmaciel 2014-07-08 15:45:06 -03:00
parent 49dbc4599e
commit 60e14a8403
3 changed files with 38 additions and 2 deletions

View File

@ -5,5 +5,4 @@
(category web)
(license "BSD")
(depends awful spiffy intarweb)
;(test-depends test)
)
(test-depends test server-test uri-common http-client))

20
tests/client.scm Normal file
View 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
View 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))))