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
5034ae33
Commit
5034ae33
authored
Jun 30, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on getting proper separation between tests.
parent
718f75a4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
45 deletions
+80
-45
converse.js
converse.js
+7
-0
spec/chatbox.js
spec/chatbox.js
+21
-21
spec/controlbox.js
spec/controlbox.js
+45
-17
spec/minchats.js
spec/minchats.js
+5
-5
tests/utils.js
tests/utils.js
+2
-2
No files found.
converse.js
View file @
5034ae33
...
...
@@ -3223,6 +3223,7 @@
this
.
model
.
on
(
"
remove
"
,
function
(
item
)
{
this
.
removeRosterItemView
(
item
);
},
this
);
this
.
model
.
on
(
"
destroy
"
,
function
(
item
)
{
this
.
removeRosterItemView
(
item
);
},
this
);
this
.
model
.
on
(
"
reset
"
,
function
()
{
this
.
removeAllRosterItemViewss
();
},
this
);
var
roster_markup
=
converse
.
templates
.
contacts
({
'
label_contacts
'
:
__
(
'
My contacts
'
)
...
...
@@ -3263,6 +3264,12 @@
return
this
;
},
removeAllRosterItemViewss
:
function
()
{
var
views
=
this
.
removeAll
();
this
.
render
();
return
this
;
},
removeRosterItemView
:
function
(
item
)
{
if
(
this
.
get
(
item
.
id
))
{
this
.
get
(
item
.
id
).
remove
();
...
...
spec/chatbox.js
View file @
5034ae33
This diff is collapsed.
Click to expand it.
spec/controlbox.js
View file @
5034ae33
...
...
@@ -205,7 +205,7 @@
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
render
();
utils
.
createCurrentContacts
();
});
waits
(
50
);
runs
(
function
()
{
...
...
@@ -218,16 +218,18 @@
},
converse
));
it
(
"
do not have a heading if there aren't any
"
,
$
.
proxy
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
none
'
);
},
converse
));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
var
i
,
t
;
converse
.
rosterview
.
model
.
reset
();
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
this
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
ask
:
null
,
fullname
:
mock
.
cur_names
[
i
],
...
...
@@ -249,8 +251,8 @@
var
item
,
view
,
jid
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
3
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
...
...
@@ -268,8 +270,8 @@
var
item
,
view
,
jid
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
3
;
i
<
6
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
...
...
@@ -279,7 +281,7 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.dnd
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
3
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
},
converse
));
...
...
@@ -287,8 +289,8 @@
var
item
,
view
,
jid
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
6
;
i
<
9
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
...
...
@@ -298,7 +300,7 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.away
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
6
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
},
converse
));
...
...
@@ -306,7 +308,7 @@
var
item
,
view
,
jid
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
9
;
i
<
12
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
render
'
).
andCallThrough
();
...
...
@@ -317,7 +319,7 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.xa
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
9
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
},
converse
));
...
...
@@ -325,7 +327,7 @@
var
item
,
view
,
jid
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
12
;
i
<
15
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
render
'
).
andCallThrough
();
...
...
@@ -336,13 +338,39 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.unavailable
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
12
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
},
converse
));
it
(
"
are ordered according to status: online, busy, away, xa, unavailable, offline
"
,
$
.
proxy
(
function
()
{
var
contacts
=
this
.
rosterview
.
$el
.
find
(
'
dd.current-xmpp-contact
'
);
var
i
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
online
'
);
}
for
(
i
=
3
;
i
<
6
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
dnd
'
);
}
for
(
i
=
6
;
i
<
9
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
away
'
);
}
for
(
i
=
9
;
i
<
12
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
xa
'
);
}
for
(
i
=
12
;
i
<
15
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
unavailable
'
);
}
var
contacts
=
this
.
rosterview
.
$el
.
find
(
'
dd.current-xmpp-contact
'
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
expect
(
$
(
contacts
[
i
]).
attr
(
'
class
'
).
split
(
'
'
,
1
)[
0
]).
toEqual
(
'
online
'
);
}
...
...
@@ -404,7 +432,7 @@
// TODO: Testing can be more thorough here, the user is
// actually not accepted/authorized because of
// mock_connection.
var
jid
=
mock
.
req_names
.
sort
()[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
jid
=
mock
.
req_names
.
sort
()[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
this
.
connection
.
roster
,
'
authorize
'
);
spyOn
(
view
,
'
acceptRequest
'
).
andCallThrough
();
...
...
@@ -467,7 +495,7 @@
// In the next test suite, we need some online contacts, so
// we make some online now
for
(
i
=
0
;
i
<
5
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
model
.
set
(
'
chat_status
'
,
'
online
'
);
}
...
...
spec/minchats.js
View file @
5034ae33
...
...
@@ -25,7 +25,7 @@
it
(
"
shows chats that have been minimized
"
,
$
.
proxy
(
function
()
{
var
contact_jid
,
chatview
;
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
chatview
=
converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
...
...
@@ -36,7 +36,7 @@
expect
(
this
.
minimized_chats
.
keys
().
length
).
toBe
(
1
);
expect
(
this
.
minimized_chats
.
keys
()[
0
]).
toBe
(
contact_jid
);
contact_jid
=
mock
.
cur_names
[
1
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
contact_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
chatview
=
converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
...
...
@@ -48,7 +48,7 @@
},
converse
));
it
(
"
can be toggled to hide or show minimized chats
"
,
$
.
proxy
(
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
var
chatview
=
converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
this
.
minimized_chats
.
$el
.
is
(
'
:visible
'
)).
toBeFalsy
();
...
...
@@ -65,11 +65,11 @@
it
(
"
shows the number messages received to minimized chats
"
,
$
.
proxy
(
function
()
{
var
i
,
contact_jid
,
chatview
,
msg
;
var
sender_jid
=
mock
.
cur_names
[
4
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
sender_jid
=
mock
.
cur_names
[
4
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
this
.
minimized_chats
.
toggleview
.
model
.
set
({
'
collapsed
'
:
true
});
expect
(
this
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
for
(
i
=
0
;
i
<
3
;
i
++
)
{
contact_jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
contact_jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
chatview
=
converse
.
chatboxviews
.
get
(
contact_jid
);
chatview
.
model
.
set
({
'
minimized
'
:
true
});
...
...
tests/utils.js
View file @
5034ae33
...
...
@@ -79,7 +79,7 @@
utils
.
openChatBoxes
=
function
(
amount
)
{
var
i
=
0
,
jid
,
views
=
[];
for
(
i
;
i
<
amount
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
views
[
i
]
=
converse
.
rosterview
.
get
(
jid
).
openChat
(
mock
.
event
);
}
return
views
;
...
...
@@ -106,7 +106,7 @@
// for the user's roster.
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
ask
:
null
,
fullname
:
mock
.
cur_names
[
i
],
...
...
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