diff --git a/awful-sse.meta b/awful-sse.meta index 7677ad7..99f6e4b 100644 --- a/awful-sse.meta +++ b/awful-sse.meta @@ -5,5 +5,4 @@ (category web) (license "BSD") (depends awful spiffy intarweb) - ;(test-depends test) - ) + (test-depends test server-test uri-common http-client)) diff --git a/tests/client.scm b/tests/client.scm new file mode 100644 index 0000000..c2f64c2 --- /dev/null +++ b/tests/client.scm @@ -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) diff --git a/tests/run.scm b/tests/run.scm new file mode 100644 index 0000000..8f1a9d6 --- /dev/null +++ b/tests/run.scm @@ -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))))