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
28d0e885
Commit
28d0e885
authored
Oct 11, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test to wait for IQ stanzas
parent
82bce1e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
spec/mam.js
spec/mam.js
+9
-13
No files found.
spec/mam.js
View file @
28d0e885
...
@@ -863,12 +863,6 @@
...
@@ -863,12 +863,6 @@
mock
.
initConverse
([],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
([],
{},
async
function
(
done
,
_converse
)
{
const
entity
=
await
_converse
.
api
.
disco
.
entities
.
get
(
_converse
.
domain
);
const
entity
=
await
_converse
.
api
.
disco
.
entities
.
get
(
_converse
.
domain
);
let
sent_stanza
,
IQ_id
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
spyOn
(
_converse
,
'
onMAMPreferences
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
onMAMPreferences
'
).
and
.
callThrough
();
_converse
.
message_archiving
=
'
never
'
;
_converse
.
message_archiving
=
'
never
'
;
...
@@ -879,9 +873,10 @@
...
@@ -879,9 +873,10 @@
entity
.
onFeatureAdded
(
feature
);
entity
.
onFeatureAdded
(
feature
);
expect
(
_converse
.
connection
.
sendIQ
).
toHaveBeenCalled
();
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
let
sent_stanza
=
await
u
.
waitUntil
(()
=>
IQ_stanzas
.
filter
(
s
=>
sizzle
(
'
iq[type="get"] prefs[xmlns="urn:xmpp:mam:2"]
'
,
s
).
length
).
pop
());
`<iq id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toBe
(
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<prefs xmlns="urn:xmpp:mam:2"/>`
+
`<prefs xmlns="urn:xmpp:mam:2"/>`
+
`</iq>`
);
`</iq>`
);
...
@@ -894,7 +889,7 @@
...
@@ -894,7 +889,7 @@
* </prefs>
* </prefs>
* </iq>
* </iq>
*/
*/
let
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
IQ_id
})
let
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
sent_stanza
.
getAttribute
(
'
id
'
)
})
.
c
(
'
prefs
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
default
'
:
'
roster
'
})
.
c
(
'
prefs
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
default
'
:
'
roster
'
})
.
c
(
'
always
'
).
c
(
'
jid
'
).
t
(
'
romeo@montague.lit
'
).
up
().
up
()
.
c
(
'
always
'
).
c
(
'
jid
'
).
t
(
'
romeo@montague.lit
'
).
up
().
up
()
.
c
(
'
never
'
).
c
(
'
jid
'
).
t
(
'
montague@montague.lit
'
);
.
c
(
'
never
'
).
c
(
'
jid
'
).
t
(
'
montague@montague.lit
'
);
...
@@ -903,8 +898,9 @@
...
@@ -903,8 +898,9 @@
await
u
.
waitUntil
(()
=>
_converse
.
onMAMPreferences
.
calls
.
count
());
await
u
.
waitUntil
(()
=>
_converse
.
onMAMPreferences
.
calls
.
count
());
expect
(
_converse
.
onMAMPreferences
).
toHaveBeenCalled
();
expect
(
_converse
.
onMAMPreferences
).
toHaveBeenCalled
();
expect
(
sent_stanza
.
toString
()).
toBe
(
sent_stanza
=
await
u
.
waitUntil
(()
=>
IQ_stanzas
.
filter
(
s
=>
sizzle
(
'
iq[type="set"] prefs[xmlns="urn:xmpp:mam:2"]
'
,
s
).
length
).
pop
());
`<iq id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toBe
(
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<prefs default="never" xmlns="urn:xmpp:mam:2">`
+
`<prefs default="never" xmlns="urn:xmpp:mam:2">`
+
`<always><jid>romeo@montague.lit</jid></always>`
+
`<always><jid>romeo@montague.lit</jid></always>`
+
`<never><jid>montague@montague.lit</jid></never>`
+
`<never><jid>montague@montague.lit</jid></never>`
+
...
@@ -924,7 +920,7 @@
...
@@ -924,7 +920,7 @@
* </prefs>
* </prefs>
* </iq>
* </iq>
*/
*/
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
IQ_id
})
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
sent_stanza
.
getAttribute
(
'
id
'
)
})
.
c
(
'
prefs
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
default
'
:
'
always
'
})
.
c
(
'
prefs
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
default
'
:
'
always
'
})
.
c
(
'
always
'
).
up
()
.
c
(
'
always
'
).
up
()
.
c
(
'
never
'
);
.
c
(
'
never
'
);
...
...
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