summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/xmpp.scm30
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/xmpp.scm b/spec/xmpp.scm
index a5f5ed8..0b9a74b 100644
--- a/spec/xmpp.scm
+++ b/spec/xmpp.scm
@@ -135,7 +135,35 @@
;; TODO
(suite "next-stanza-id!" (tests))
-(suite "handle-stanza" (tests))
+(suite "handle-stanza"
+ (tests
+ (test "calls id handler first, then generic handler" e
+ (assert-equal
+ '(generic-handler id-handler)
+ (let ((results '()))
+ (register-stanza-handler
+ (lambda _ (set! results (cons 'generic-handler results))))
+ (register-temp-stanza-handler-for-id
+ (stanza-id (e 'stanza))
+ (lambda _ (set! results (cons 'id-handler results))))
+ ((@@ (gnubba xmpp) handle-stanza) (e 'stanza))
+ results)))
+ (test "catches 'halt" e
+ (assert-false
+ (error?
+ (begin
+ (register-stanza-handler
+ (lambda _ (throw 'never-executed)))
+ (register-temp-stanza-handler-for-id
+ (stanza-id (e 'stanza))
+ (lambda _ (throw 'halt)))
+ ((@@ (gnubba xmpp) handle-stanza) (e 'stanza)))))))
+ (options)
+ (setups
+ (setup 'stanza (iq "payload" #:to "romeo@capulet.it" #:id "1234")))
+ (teardowns
+ ;; always reset the internal state after each test
+ (teardown e (set! (@@ (gnubba xmpp) *stanza-handlers*) '()))))
(suite "run-handler-loop"
(tests