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
3a375772
Commit
3a375772
authored
Apr 30, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to not have to rely on a spy
parent
4bcf8e7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
tests/utils.js
tests/utils.js
+19
-13
No files found.
tests/utils.js
View file @
3a375772
...
@@ -125,28 +125,35 @@
...
@@ -125,28 +125,35 @@
};
};
utils
.
openAndEnterChatRoom
=
function
(
_converse
,
room
,
server
,
nick
)
{
utils
.
openAndEnterChatRoom
=
function
(
_converse
,
room
,
server
,
nick
)
{
let
last_stanza
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
sinon
.
spy
(
_converse
.
connection
,
'
sendIQ
'
);
_converse
.
api
.
rooms
.
open
(
`
${
room
}
@
${
server
}
`
);
_converse
.
api
.
rooms
.
open
(
`
${
room
}
@
${
server
}
`
);
var
view
=
_converse
.
chatboxviews
.
get
((
room
+
'
@
'
+
server
).
toLowerCase
());
const
view
=
_converse
.
chatboxviews
.
get
((
room
+
'
@
'
+
server
).
toLowerCase
());
// We pretend this is a new room, so no disco info is returned.
// We pretend this is a new room, so no disco info is returned.
var
IQ_id
=
_converse
.
connection
.
sendIQ
.
firstCall
.
returnValue
;
last_stanza
=
_
.
last
(
_converse
.
connection
.
IQ_stanzas
).
nodeTree
;
var
features_stanza
=
$iq
({
const
IQ_id
=
last_stanza
.
getAttribute
(
'
id
'
);
const
features_stanza
=
$iq
({
'
from
'
:
room
+
'
@
'
+
server
,
'
from
'
:
room
+
'
@
'
+
server
,
'
id
'
:
IQ_id
,
'
id
'
:
IQ_id
,
'
to
'
:
nick
+
'
@
'
+
server
+
'
/desktop
'
,
'
to
'
:
nick
+
'
@
'
+
server
,
'
type
'
:
'
error
'
'
type
'
:
'
error
'
}).
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
}).
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
.
c
(
'
item-not-found
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
});
.
c
(
'
item-not-found
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
});
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
features_stanza
));
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
features_stanza
));
utils
.
waitUntil
(
function
()
{
utils
.
waitUntil
(()
=>
{
return
_converse
.
connection
.
sendIQ
.
secondCall
;
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
node
.
nodeTree
.
querySelector
(
'
query
'
).
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
).
length
}).
then
(
function
()
{
}).
then
(
function
()
{
const
last_stanza
=
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
node
.
nodeTree
.
querySelector
(
'
query
'
).
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
).
pop
().
nodeTree
;
// The XMPP server returns the reserved nick for this user.
// The XMPP server returns the reserved nick for this user.
IQ_id
=
_converse
.
connection
.
sendIQ
.
secondCall
.
returnValue
;
const
IQ_id
=
last_stanza
.
getAttribute
(
'
id
'
)
;
var
stanza
=
$iq
({
const
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
id
'
:
IQ_id
,
'
id
'
:
IQ_id
,
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
...
@@ -169,10 +176,9 @@
...
@@ -169,10 +176,9 @@
}).
up
()
}).
up
()
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
});
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
});
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
presence
));
_converse
.
connection
.
sendIQ
.
restore
();
resolve
();
resolve
();
})
.
catch
(
_
.
partial
(
console
.
error
,
_
))
;
});
})
.
catch
(
_
.
partial
(
console
.
error
,
_
))
;
});
};
};
utils
.
clearBrowserStorage
=
function
()
{
utils
.
clearBrowserStorage
=
function
()
{
...
...
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