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
79b6a557
Commit
79b6a557
authored
May 22, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await and hopefully fix some failing Travis tests
parent
7ab59ad6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
225 additions
and
274 deletions
+225
-274
spec/roster.js
spec/roster.js
+225
-274
No files found.
spec/roster.js
View file @
79b6a557
...
@@ -297,64 +297,57 @@
...
@@ -297,64 +297,57 @@
it
(
"
has a button with which its contents can be cleared
"
,
it
(
"
has a button with which its contents can be cleared
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
roster_groups
=
true
;
_converse
.
roster_groups
=
true
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
createGroupedContacts
(
_converse
);
test_utils
.
createGroupedContacts
(
_converse
);
var
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
const
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
filter
.
value
=
"
xxx
"
;
filter
.
value
=
"
xxx
"
;
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
expect
(
_
.
includes
(
filter
.
classList
,
"
x
"
)).
toBeFalsy
();
expect
(
_
.
includes
(
filter
.
classList
,
"
x
"
)).
toBeFalsy
();
expect
(
u
.
hasClass
(
'
hidden
'
,
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter-form .clear-input
'
))).
toBeTruthy
();
expect
(
u
.
hasClass
(
'
hidden
'
,
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter-form .clear-input
'
))).
toBeTruthy
();
test_utils
.
waitUntil
(
function
()
{
const
isHidden
=
_
.
partial
(
u
.
hasClass
,
'
hidden
'
);
return
!
u
.
hasClass
(
'
hidden
'
,
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter-form .clear-input
'
));
await
test_utils
.
waitUntil
(()
=>
!
isHidden
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter-form .clear-input
'
)),
900
);
},
900
).
then
(
function
()
{
_converse
.
rosterview
.
el
.
querySelector
(
'
.clear-input
'
).
click
();
var
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
expect
(
document
.
querySelector
(
'
.roster-filter
'
).
value
).
toBe
(
""
);
_converse
.
rosterview
.
el
.
querySelector
(
'
.clear-input
'
).
click
();
done
();
expect
(
document
.
querySelector
(
'
.roster-filter
'
).
value
).
toBe
(
""
);
done
();
});
}));
}));
it
(
"
can be used to filter contacts by their chat state
"
,
it
(
"
can be used to filter contacts by their chat state
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createGroupedContacts
(
_converse
);
test_utils
.
createGroupedContacts
(
_converse
);
var
jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
jid
=
mock
.
cur_names
[
4
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
jid
=
mock
.
cur_names
[
4
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
var
button
=
_converse
.
rosterview
.
el
.
querySelector
(
'
span[data-type="state"]
'
);
const
button
=
_converse
.
rosterview
.
el
.
querySelector
(
'
span[data-type="state"]
'
);
button
.
click
();
button
.
click
();
var
roster
=
_converse
.
rosterview
.
roster_el
;
const
roster
=
_converse
.
rosterview
.
roster_el
;
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
,
500
).
then
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
,
500
);
var
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.state-type
'
);
const
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.state-type
'
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
5
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
5
);
filter
.
value
=
"
online
"
;
filter
.
value
=
"
online
"
;
u
.
triggerEvent
(
filter
,
'
change
'
);
u
.
triggerEvent
(
filter
,
'
change
'
);
return
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
500
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
500
);
}).
then
(
function
()
{
expect
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()).
toBe
(
'
Rinse Sommer
'
);
expect
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()).
toBe
(
'
Rinse Sommer
'
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
500
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
const
ul
=
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
pop
();
expect
(
ul
.
parentElement
.
firstElementChild
.
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
var
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.state-type
'
);
filter
.
value
=
"
dnd
"
;
filter
.
value
=
"
dnd
"
;
u
.
triggerEvent
(
filter
,
'
change
'
);
u
.
triggerEvent
(
filter
,
'
change
'
);
return
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()
===
'
Annegreet Gomez
'
,
900
);
return
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()
===
'
Annegreet Gomez
'
;
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
},
900
)
done
();
}).
then
(
function
()
{
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
}));
});
});
...
@@ -443,7 +436,7 @@
...
@@ -443,7 +436,7 @@
done
();
done
();
}));
}));
it
(
"
can share contacts with other roster groups
"
,
it
(
"
can share contacts with other roster groups
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
roster_groups
'
:
true
},
null
,
[
'
rosterGroupsFetched
'
],
{
'
roster_groups
'
:
true
},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -517,7 +510,7 @@
...
@@ -517,7 +510,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
}
}
it
(
"
can be collapsed under their own header
"
,
it
(
"
can be collapsed under their own header
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -548,7 +541,7 @@
...
@@ -548,7 +541,7 @@
done
();
done
();
}));
}));
it
(
"
are shown in the roster when show_only_online_users
"
,
it
(
"
are shown in the roster when show_only_online_users
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -565,7 +558,7 @@
...
@@ -565,7 +558,7 @@
done
();
done
();
}));
}));
it
(
"
are shown in the roster when hide_offline_users
"
,
it
(
"
are shown in the roster when hide_offline_users
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
hide_offline_users
'
:
true
},
null
,
[
'
rosterGroupsFetched
'
],
{
'
hide_offline_users
'
:
true
},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -580,7 +573,7 @@
...
@@ -580,7 +573,7 @@
done
();
done
();
}));
}));
it
(
"
can be removed by the user
"
,
it
(
"
can be removed by the user
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -612,7 +605,7 @@
...
@@ -612,7 +605,7 @@
done
();
done
();
}));
}));
it
(
"
do not have a header if there aren't any
"
,
it
(
"
do not have a header if there aren't any
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -633,7 +626,7 @@
...
@@ -633,7 +626,7 @@
const
el
=
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
;
const
el
=
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
;
return
u
.
isVisible
(
el
)
&&
_
.
filter
(
el
.
querySelectorAll
(
'
li
'
),
li
=>
u
.
isVisible
(
li
)).
length
;
return
u
.
isVisible
(
el
)
&&
_
.
filter
(
el
.
querySelectorAll
(
'
li
'
),
li
=>
u
.
isVisible
(
li
)).
length
;
},
700
)
},
700
)
sizzle
(
`.remove-xmpp-contact[title="Click to remove
${
name
}
as a contact"]`
,
_converse
.
rosterview
.
el
).
pop
().
click
();
sizzle
(
`.remove-xmpp-contact[title="Click to remove
${
name
}
as a contact"]`
,
_converse
.
rosterview
.
el
).
pop
().
click
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
_converse
.
connection
.
sendIQ
).
toHaveBeenCalled
();
expect
(
_converse
.
connection
.
sendIQ
).
toHaveBeenCalled
();
...
@@ -661,9 +654,9 @@
...
@@ -661,9 +654,9 @@
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
i
,
t
;
let
i
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
i
=
0
;
i
<
mock
.
pend_names
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
pend_names
.
length
;
i
++
)
{
...
@@ -675,17 +668,13 @@
...
@@ -675,17 +668,13 @@
});
});
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
}
}
return
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
).
filter
(
u
.
isVisible
).
length
,
700
);
return
sizzle
(
'
li
'
,
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
).
filter
(
u
.
isVisible
).
length
;
// Check that they are sorted alphabetically
},
700
).
then
(
function
()
{
const
view
=
_converse
.
rosterview
.
get
(
'
Pending contacts
'
);
// Check that they are sorted alphabetically
const
spans
=
view
.
el
.
querySelectorAll
(
'
.pending-xmpp-contact span
'
);
t
=
_
.
reduce
(
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
.
querySelectorAll
(
'
.pending-xmpp-contact span
'
),
const
t
=
_
.
reduce
(
spans
,
(
result
,
value
)
=>
result
+
_
.
trim
(
value
.
textContent
),
''
);
function
(
result
,
value
)
{
expect
(
t
).
toEqual
(
mock
.
pend_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
return
result
+
_
.
trim
(
value
.
textContent
);
done
();
},
''
);
expect
(
t
).
toEqual
(
mock
.
pend_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
done
();
});
}));
}));
});
});
...
@@ -694,57 +683,49 @@
...
@@ -694,57 +683,49 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
).
openControlBox
()
test_utils
.
createContacts
(
_converse
,
'
current
'
).
openControlBox
()
}
}
it
(
"
can be collapsed under their own header
"
,
it
(
"
can be collapsed under their own header
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
500
);
return
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
;
await
checkHeaderToggling
.
apply
(
_converse
,
[
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group
'
)]);
},
500
).
then
(
function
()
{
done
();
checkHeaderToggling
.
apply
(
_converse
,
[
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group
'
)]
).
then
(
done
);
});
}));
}));
it
(
"
will be hidden when appearing under a collapsed group
"
,
it
(
"
will be hidden when appearing under a collapsed group
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
roster_groups
=
false
;
_converse
.
roster_groups
=
false
;
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
500
);
return
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
;
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group a.group-toggle
'
).
click
();
},
500
)
const
name
=
"
Max Mustermann
"
;
.
then
(
function
()
{
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group a.group-toggle
'
).
click
();
_converse
.
roster
.
create
({
var
name
=
"
Max Mustermann
"
;
ask
:
null
,
var
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
fullname
:
name
,
_converse
.
roster
.
create
({
jid
:
jid
,
ask
:
null
,
requesting
:
false
,
fullname
:
name
,
subscription
:
'
both
'
jid
:
jid
,
requesting
:
false
,
subscription
:
'
both
'
});
var
view
=
_converse
.
rosterview
.
get
(
'
My contacts
'
).
get
(
jid
);
expect
(
u
.
isVisible
(
view
.
el
)).
toBe
(
false
);
done
();
});
});
const
view
=
_converse
.
rosterview
.
get
(
'
My contacts
'
).
get
(
jid
);
expect
(
u
.
isVisible
(
view
.
el
)).
toBe
(
false
);
done
();
}));
}));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
i
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
...
@@ -753,20 +734,17 @@
...
@@ -753,20 +734,17 @@
});
});
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
}
}
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
length
,
600
);
return
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
length
;
// Check that they are sorted alphabetically
},
600
).
then
(
function
()
{
const
t
=
_
.
reduce
(
// Check that they are sorted alphabetically
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.offline a.open-chat
'
),
const
t
=
_
.
reduce
(
(
result
,
value
)
=>
(
result
+
value
.
textContent
.
trim
()),
''
);
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.offline a.open-chat
'
),
(
result
,
value
)
=>
(
result
+
value
.
textContent
.
trim
()),
''
);
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
done
();
done
();
});
}));
}));
it
(
"
can be removed by the user
"
,
it
(
"
can be removed by the user
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -796,7 +774,7 @@
...
@@ -796,7 +774,7 @@
done
();
done
();
}));
}));
it
(
"
do not have a header if there aren't any
"
,
it
(
"
do not have a header if there aren't any
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -825,86 +803,73 @@
...
@@ -825,86 +803,73 @@
done
();
done
();
}));
}));
it
(
"
can change their status to online and be sorted alphabetically
"
,
it
(
"
can change their status to online and be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
,
700
)
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
,
700
);
.
then
(
function
()
{
let
jid
,
t
;
var
jid
,
t
;
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
const
roster
=
_converse
.
rosterview
.
el
;
const
roster
=
_converse
.
rosterview
.
el
;
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
const
chat_els
=
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.online a.open-chat
'
);
t
=
_
.
reduce
(
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.online a.open-chat
'
),
function
(
result
,
value
)
{
t
=
_
.
reduce
(
chat_els
,
(
result
,
value
)
=>
result
+
_
.
trim
(
value
.
textContent
),
''
);
return
result
+
_
.
trim
(
value
.
textContent
);
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
},
''
);
}
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
done
();
}
done
();
});
}));
}));
it
(
"
can change their status to busy and be sorted alphabetically
"
,
it
(
"
can change their status to busy and be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
return
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
;
let
jid
,
t
;
},
700
).
then
(
function
()
{
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
var
jid
,
t
;
const
roster
=
_converse
.
rosterview
.
el
;
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
const
roster
=
_converse
.
rosterview
.
el
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
// Check that they are sorted alphabetically
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
const
chat_els
=
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.dnd a.open-chat
'
);
// Check that they are sorted alphabetically
t
=
_
.
reduce
(
chat_els
,
(
result
,
value
)
=>
result
+
_
.
trim
(
value
.
textContent
),
''
);
t
=
_
.
reduce
(
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.dnd a.open-chat
'
),
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
function
(
result
,
value
)
{
}
return
result
+
_
.
trim
(
value
.
textContent
);
done
();
},
''
);
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
done
();
});
}));
}));
it
(
"
can change their status to away and be sorted alphabetically
"
,
it
(
"
can change their status to away and be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
return
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
;
let
jid
,
t
;
},
700
).
then
(
function
()
{
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
var
jid
,
t
;
const
roster
=
_converse
.
rosterview
.
el
;
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
const
roster
=
_converse
.
rosterview
.
el
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
// Check that they are sorted alphabetically
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
const
chat_els
=
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.away a.open-chat
'
);
// Check that they are sorted alphabetically
t
=
_
.
reduce
(
chat_els
,
(
result
,
value
)
=>
result
+
_
.
trim
(
value
.
textContent
),
''
);
t
=
_
.
reduce
(
roster
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact.away a.open-chat
'
),
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
function
(
result
,
value
)
{
}
return
result
+
_
.
trim
(
value
.
textContent
);
done
();
},
''
);
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
}
done
();
});
}));
}));
it
(
"
can change their status to xa and be sorted alphabetically
"
,
it
(
"
can change their status to xa and be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -928,7 +893,7 @@
...
@@ -928,7 +893,7 @@
done
();
done
();
}));
}));
it
(
"
can change their status to unavailable and be sorted alphabetically
"
,
it
(
"
can change their status to unavailable and be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -952,102 +917,92 @@
...
@@ -952,102 +917,92 @@
done
();
done
();
}));
}));
it
(
"
are ordered according to status: online, busy, away, xa, unavailable, offline
"
,
it
(
"
are ordered according to status: online, busy, away, xa, unavailable, offline
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_addContacts
(
_converse
);
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
return
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
;
let
i
,
jid
;
},
700
).
then
(
function
()
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
var
i
,
jid
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
}
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
for
(
i
=
3
;
i
<
6
;
i
++
)
{
}
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
3
;
i
<
6
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
}
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
for
(
i
=
6
;
i
<
9
;
i
++
)
{
}
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
6
;
i
<
9
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
}
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
for
(
i
=
9
;
i
<
12
;
i
++
)
{
}
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
9
;
i
<
12
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
}
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
for
(
i
=
12
;
i
<
15
;
i
++
)
{
}
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
for
(
i
=
12
;
i
<
15
;
i
++
)
{
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
}
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li.online
'
).
length
)
}
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelector
(
'
li:first-child
'
).
textContent
.
trim
()
===
'
Candice van der Knijff
'
,
900
);
return
test_utils
.
waitUntil
(
function
()
{
const
contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.current-xmpp-contact
'
);
return
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li.online
'
).
length
for
(
i
=
0
;
i
<
3
;
i
++
)
{
})
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
true
);
}).
then
(
function
()
{
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
return
test_utils
.
waitUntil
(
function
()
{
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
return
_converse
.
rosterview
.
el
.
querySelector
(
'
li:first-child
'
).
textContent
.
trim
()
===
'
Candice van der Knijff
'
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
},
900
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
}).
then
(
function
()
{
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
var
i
;
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
const
contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.current-xmpp-contact
'
);
}
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
3
;
i
<
6
;
i
++
)
{
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
}
}
for
(
i
=
3
;
i
<
6
;
i
++
)
{
for
(
i
=
6
;
i
<
9
;
i
++
)
{
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
}
}
for
(
i
=
6
;
i
<
9
;
i
++
)
{
for
(
i
=
9
;
i
<
12
;
i
++
)
{
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
}
}
for
(
i
=
9
;
i
<
12
;
i
++
)
{
for
(
i
=
12
;
i
<
15
;
i
++
)
{
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
}
}
for
(
i
=
12
;
i
<
15
;
i
++
)
{
for
(
i
=
15
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
}
}
for
(
i
=
15
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
done
();
expect
(
u
.
hasClass
(
'
offline
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
both
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
away
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
xa
'
,
contacts
[
i
])).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
unavailable
'
,
contacts
[
i
])).
toBe
(
false
);
}
done
();
});
}));
}));
});
});
...
@@ -1056,18 +1011,17 @@
...
@@ -1056,18 +1011,17 @@
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
i
,
children
;
let
names
=
[];
var
names
=
[];
const
addName
=
function
(
item
)
{
var
addName
=
function
(
item
)
{
if
(
!
u
.
hasClass
(
'
request-actions
'
,
item
))
{
if
(
!
u
.
hasClass
(
'
request-actions
'
,
item
))
{
names
.
push
(
item
.
textContent
.
replace
(
/^
\s
+|
\s
+$/g
,
''
));
names
.
push
(
item
.
textContent
.
replace
(
/^
\s
+|
\s
+$/g
,
''
));
}
}
};
};
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
controlboxtoggle
,
'
showControlBox
'
).
and
.
callThrough
();
spyOn
(
_converse
.
controlboxtoggle
,
'
showControlBox
'
).
and
.
callThrough
();
for
(
i
=
0
;
i
<
mock
.
req_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
req_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
req_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
jid
:
mock
.
req_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
...
@@ -1076,20 +1030,17 @@
...
@@ -1076,20 +1030,17 @@
fullname
:
mock
.
req_names
[
i
]
fullname
:
mock
.
req_names
[
i
]
});
});
}
}
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
li
'
).
length
,
700
);
return
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
li
'
).
length
;
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
},
700
).
then
(
function
()
{
// Check that they are sorted alphabetically
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
const
children
=
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
.requesting-xmpp-contact span
'
);
// Check that they are sorted alphabetically
names
=
[];
children
=
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
.requesting-xmpp-contact span
'
);
Array
.
from
(
children
).
forEach
(
addName
);
names
=
[];
expect
(
names
.
join
(
''
)).
toEqual
(
mock
.
req_names
.
slice
(
0
,
mock
.
req_names
.
length
+
1
).
sort
().
join
(
''
));
_
.
each
(
children
,
addName
);
done
();
expect
(
names
.
join
(
''
)).
toEqual
(
mock
.
req_names
.
slice
(
0
,
mock
.
req_names
.
length
+
1
).
sort
().
join
(
''
));
done
();
});
}));
}));
it
(
"
do not have a header if there aren't any
"
,
it
(
"
do not have a header if there aren't any
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -1113,7 +1064,7 @@
...
@@ -1113,7 +1064,7 @@
done
();
done
();
}));
}));
it
(
"
can be collapsed under their own header
"
,
it
(
"
can be collapsed under their own header
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -1127,7 +1078,7 @@
...
@@ -1127,7 +1078,7 @@
done
();
done
();
}));
}));
it
(
"
can have their requests accepted by the user
"
,
it
(
"
can have their requests accepted by the user
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -1151,7 +1102,7 @@
...
@@ -1151,7 +1102,7 @@
done
();
done
();
}));
}));
it
(
"
can have their requests denied by the user
"
,
it
(
"
can have their requests denied by the user
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -1245,7 +1196,7 @@
...
@@ -1245,7 +1196,7 @@
done
();
done
();
}));
}));
it
(
"
will show fullname and jid properties on tooltip
"
,
it
(
"
will show fullname and jid properties on tooltip
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
...
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