Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5e1b0948
Commit
5e1b0948
authored
Dec 02, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand upon `rooms.open` testcase to test configuration
parent
910e9bdd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
3 deletions
+92
-3
spec/chatroom.js
spec/chatroom.js
+90
-1
src/converse-muc.js
src/converse-muc.js
+2
-2
No files found.
spec/chatroom.js
View file @
5e1b0948
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
});
});
}));
}));
it
(
"
has a method 'open' which opens and returns a wrapped chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
has a method 'open' which opens
(optionally configures)
and returns a wrapped chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
var
chatroomview
;
var
chatroomview
;
var
jid
=
'
lounge@localhost
'
;
var
jid
=
'
lounge@localhost
'
;
...
@@ -138,6 +138,94 @@
...
@@ -138,6 +138,94 @@
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
chatroomview
.
close
();
});
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
converse
.
muc_instant_rooms
=
false
;
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
spyOn
(
converse
.
connection
,
'
sendIQ
'
).
andCallFake
(
function
(
iq
,
callback
,
errback
)
{
sent_IQ
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
// Test with configuration
converse_api
.
rooms
.
open
(
'
room@conference.example.org
'
,
{
'
nick
'
:
'
some1
'
,
'
auto_configure
'
:
true
,
'
roomconfig
'
:
{
'
changesubject
'
:
false
,
'
membersonly
'
:
true
,
'
persistentroom
'
:
true
,
'
publicroom
'
:
true
,
'
roomdesc
'
:
'
Welcome to this room
'
,
'
whois
'
:
'
anyone
'
}
});
/* <presence xmlns="jabber:client" to="dummy@localhost/pda" from="room@conference.example.org/yo">
* <x xmlns="http://jabber.org/protocol/muc#user">
* <item affiliation="owner" jid="dummy@localhost/pda" role="moderator"/>
* <status code="110"/>
* <status code="201"/>
* </x>
* </presence>
*/
var
presence
=
$pres
({
from
:
'
room@conference.example.org/some1
'
,
to
:
'
dummy@localhost/pda
'
})
.
c
(
'
x
'
,
{
xmlns
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
affiliation
:
'
owner
'
,
jid
:
'
dummy@localhost/pda
'
,
role
:
'
moderator
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
110
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
201
'
});
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
converse
.
connection
.
sendIQ
).
toHaveBeenCalled
();
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
"
<iq to='room@conference.example.org' type='get' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'><query xmlns='http://jabber.org/protocol/muc#owner'/></iq>
"
);
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$
(
'
<iq xmlns="jabber:client"
'
+
'
type="result"
'
+
'
to="dummy@localhost/pda"
'
+
'
from="room@conference.example.org" id="
'
+
IQ_id
+
'
">
'
+
'
<query xmlns="http://jabber.org/protocol/muc#owner">
'
+
'
<x xmlns="jabber:x:data" type="form">
'
+
'
<title>Configuration for room@conference.example.org</title>
'
+
'
<instructions>Complete and submit this form to configure the room.</instructions>
'
+
'
<field var="FORM_TYPE" type="hidden">
'
+
'
<value>http://jabber.org/protocol/muc#roomconfig</value>
'
+
'
</field>
'
+
'
<field type="text-single" var="muc#roomconfig_roomname" label="Name">
'
+
'
<value>Room</value>
'
+
'
</field>
'
+
'
<field type="text-single" var="muc#roomconfig_roomdesc" label="Description"><value/></field>
'
+
'
<field type="boolean" var="muc#roomconfig_persistentroom" label="Make Room Persistent?"/>
'
+
'
<field type="boolean" var="muc#roomconfig_publicroom" label="Make Room Publicly Searchable?"><value>1</value></field>
'
+
'
<field type="boolean" var="muc#roomconfig_changesubject" label="Allow Occupants to Change Subject?"/>
'
+
'
<field type="list-single" var="muc#roomconfig_whois" label="Who May Discover Real JIDs?"><option label="Moderators Only">
'
+
'
<value>moderators</value></option><option label="Anyone"><value>anyone</value></option>
'
+
'
</field>
'
+
'
<field type="text-private" var="muc#roomconfig_roomsecret" label="Password"><value/></field>
'
+
'
<field type="boolean" var="muc#roomconfig_moderatedroom" label="Make Room Moderated?"/>
'
+
'
<field type="boolean" var="muc#roomconfig_membersonly" label="Make Room Members-Only?"/>
'
+
'
<field type="text-single" var="muc#roomconfig_historylength" label="Maximum Number of History Messages Returned by Room">
'
+
'
<value>20</value></field>
'
+
'
</x>
'
+
'
</query>
'
+
'
</iq>
'
)[
0
]));
var
$sent_stanza
=
$
(
sent_IQ
.
toLocaleString
());
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_roomname"] value
'
).
text
()).
toBe
(
'
Room
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_roomdesc"] value
'
).
text
()).
toBe
(
'
Welcome to this room
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_persistentroom"] value
'
).
text
()).
toBe
(
'
1
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_publicroom"] value
'
).
text
()).
toBe
(
'
1
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_changesubject"] value
'
).
text
()).
toBe
(
'
0
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_whois"] value
'
).
text
()).
toBe
(
'
anyone
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_membersonly"] value
'
).
text
()).
toBe
(
'
1
'
);
expect
(
$sent_stanza
.
find
(
'
field[var="muc#roomconfig_historylength"] value
'
).
text
()).
toBe
(
'
20
'
);
});
}));
}));
});
});
...
@@ -608,6 +696,7 @@
...
@@ -608,6 +696,7 @@
it
(
"
indicates when a room is no longer anonymous
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
indicates when a room is no longer anonymous
"
,
mock
.
initConverse
(
function
(
converse
)
{
converse_api
.
rooms
.
open
(
'
room@conference.example.org
'
,
{
converse_api
.
rooms
.
open
(
'
room@conference.example.org
'
,
{
'
nick
'
:
'
some1
'
,
'
nick
'
:
'
some1
'
,
'
auto_configure
'
:
true
,
'
roomconfig
'
:
{
'
roomconfig
'
:
{
'
changesubject
'
:
false
,
'
changesubject
'
:
false
,
'
membersonly
'
:
true
,
'
membersonly
'
:
true
,
...
...
src/converse-muc.js
View file @
5e1b0948
...
@@ -816,7 +816,7 @@
...
@@ -816,7 +816,7 @@
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
"
submit
"
});
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
"
submit
"
});
_
.
each
(
config
,
function
(
node
)
{
iq
.
cnode
(
node
).
up
();
});
_
.
each
(
config
,
function
(
node
)
{
iq
.
cnode
(
node
).
up
();
});
return
converse
.
connection
.
sendIQ
(
iq
.
tree
()
,
onSuccess
,
onError
);
return
converse
.
connection
.
sendIQ
(
iq
,
onSuccess
,
onError
);
},
},
saveConfiguration
:
function
(
ev
)
{
saveConfiguration
:
function
(
ev
)
{
...
@@ -920,7 +920,7 @@
...
@@ -920,7 +920,7 @@
$iq
({
$iq
({
'
to
'
:
this
.
model
.
get
(
'
jid
'
),
'
to
'
:
this
.
model
.
get
(
'
jid
'
),
'
type
'
:
"
get
"
'
type
'
:
"
get
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
tree
()
,
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
}),
handleIQ
handleIQ
);
);
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment