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
762e2bac
Commit
762e2bac
authored
Mar 01, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write a test for rooms listing.
parent
c7d5b8b1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
44 deletions
+61
-44
converse.js
converse.js
+36
-32
spec/controlbox.js
spec/controlbox.js
+25
-12
No files found.
converse.js
View file @
762e2bac
...
...
@@ -1789,17 +1789,10 @@
$
(
'
input#show-rooms
'
).
show
().
siblings
(
'
span.spinner
'
).
remove
();
},
updateRoomsList
:
function
()
{
/* Send and IQ stanza to the server asking for all rooms
onRoomsFound
:
function
(
iq
)
{
/* Handle the IQ stanza returned from the server, containing
* all its public rooms.
*/
converse
.
connection
.
sendIQ
(
$iq
({
to
:
this
.
model
.
get
(
'
muc_domain
'
),
from
:
converse
.
connection
.
jid
,
type
:
"
get
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
DISCO_ITEMS
}),
// Succcess Handler
$
.
proxy
(
function
(
iq
)
{
var
name
,
jid
,
i
,
fragment
,
that
=
this
,
$available_chatrooms
=
this
.
$el
.
find
(
'
#available-chatrooms
'
);
...
...
@@ -1827,9 +1820,20 @@
this
.
informNoRoomsFound
();
}
return
true
;
},
this
),
// Error handler
$
.
proxy
(
function
(
iq
)
{
this
.
informNoRoomsFound
();
},
this
));
},
updateRoomsList
:
function
()
{
/* Send and IQ stanza to the server asking for all rooms
*/
converse
.
connection
.
sendIQ
(
$iq
({
to
:
this
.
model
.
get
(
'
muc_domain
'
),
from
:
converse
.
connection
.
jid
,
type
:
"
get
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
DISCO_ITEMS
}),
$
.
proxy
(
function
(
iq
)
{
this
.
onRoomsFound
();
},
this
),
$
.
proxy
(
function
(
iq
)
{
this
.
informNoRoomsFound
();
},
this
)
);
},
showRooms
:
function
(
ev
)
{
...
...
spec/controlbox.js
View file @
762e2bac
...
...
@@ -1076,15 +1076,10 @@
var
$chatrooms
=
$panels
.
children
().
last
();
spyOn
(
cbview
,
'
switchTab
'
).
andCallThrough
();
cbview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
runs
(
function
()
{
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Clicks the chatrooms tab
});
waits
(
250
);
runs
(
function
()
{
expect
(
$contacts
.
is
(
'
:visible
'
)).
toBe
(
false
);
expect
(
$chatrooms
.
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
cbview
.
switchTab
).
toHaveBeenCalled
();
});
},
converse
));
it
(
"
contains a form through which a new chatroom can be created
"
,
$
.
proxy
(
function
()
{
...
...
@@ -1113,11 +1108,29 @@
},
converse
));
},
converse
));
it
(
"
lists rooms currently on the server
"
,
$
.
proxy
(
function
()
{
// TODO: test updateRoomsList
it
(
"
can list rooms publically available on the server
"
,
$
.
proxy
(
function
()
{
var
panel
=
this
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
panel
.
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the chatrooms tab
panel
.
model
.
set
({
'
muc_domain
'
:
'
muc.localhost
'
});
// Make sure the domain is set
// See: http://xmpp.org/extensions/xep-0045.html#disco-rooms
expect
(
$
(
'
#available-chatrooms
'
).
children
(
'
dt
'
).
length
).
toBe
(
0
);
expect
(
$
(
'
#available-chatrooms
'
).
children
(
'
dd
'
).
length
).
toBe
(
0
);
var
iq
=
$iq
({
from
:
'
muc.localhost
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
result
'
}).
c
(
'
query
'
)
.
c
(
'
item
'
,
{
jid
:
'
heath@chat.shakespeare.lit
'
,
name
:
'
A Lonely Heath
'
}).
up
()
.
c
(
'
item
'
,
{
jid
:
'
coven@chat.shakespeare.lit
'
,
name
:
'
A Dark Cave
'
}).
up
()
.
c
(
'
item
'
,
{
jid
:
'
forres@chat.shakespeare.lit
'
,
name
:
'
The Palace
'
}).
up
()
.
c
(
'
item
'
,
{
jid
:
'
inverness@chat.shakespeare.lit
'
,
name
:
'
Macbeth's Castle
'
}).
nodeTree
;
panel
.
onRoomsFound
(
iq
);
expect
(
panel
.
$
(
'
#available-chatrooms
'
).
children
(
'
dt
'
).
length
).
toBe
(
1
);
expect
(
panel
.
$
(
'
#available-chatrooms
'
).
children
(
'
dt
'
).
first
().
text
()).
toBe
(
"
Rooms on muc.localhost
"
);
expect
(
panel
.
$
(
'
#available-chatrooms
'
).
children
(
'
dd
'
).
length
).
toBe
(
4
);
},
converse
));
},
converse
));
},
converse
,
mock
,
test_utils
));
}));
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