AtlatestRepositorysigil-xmpp
sigil-xmpp / tree / testtest-muc.sgl
1
(import (sigil test)2
(sigil string)3
(sigil xmpp stanza)4
(sigil xmpp muc))6
;; ============================================================7
;; MUC Data Structures8
;; ============================================================10
(test-group "muc-structs"11
(test "create muc-room"12
(let ((room (muc-room jid: "[email protected]" nick: "bot")))13
(assert-equal "[email protected]" (muc-room-jid room))14
(assert-equal "bot" (muc-room-nick room))15
(assert-false (muc-room-joined? room))))17
(test "create muc-occupant"18
(let ((occ (muc-occupant nick: "alice"19
jid: "[email protected]/res"20
affiliation: "member"21
role: "participant")))22
(assert-equal "alice" (muc-occupant-nick occ))23
(assert-equal "[email protected]/res" (muc-occupant-jid occ))24
(assert-equal "member" (muc-occupant-affiliation occ))25
(assert-equal "participant" (muc-occupant-role occ)))))27
;; ============================================================28
;; MUC Message Construction29
;; ============================================================31
(test-group "muc-messages"32
(test "groupchat message"33
(let ((msg (xmpp-message to: "[email protected]" type: "groupchat"34
body: "Hello room" id: "m1")))35
(assert-equal "groupchat" (stanza-attr msg 'type))36
(assert-equal "[email protected]" (stanza-to msg))37
(assert-equal "Hello room" (message-body msg))))39
(test "MUC join presence has x element"40
(let ((p (xmpp-presence41
to: "[email protected]/bot"42
children: (list '(x (@ (xmlns "http://jabber.org/protocol/muc")))))))43
(assert-equal "[email protected]/bot" (stanza-to p))44
(let ((x (stanza-child p 'x)))45
(assert-true (pair? x))))))47
(run-tests)