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
ade08104
Commit
ade08104
authored
Apr 09, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish tests for the "happy path" of the add/subscribe protocol
parent
2e11f99d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
7 deletions
+45
-7
spec/protocol.js
spec/protocol.js
+45
-7
No files found.
spec/protocol.js
View file @
ade08104
...
...
@@ -54,7 +54,7 @@
test_utils
.
openContactsPanel
();
});
it
(
"
User Subscribes to C
ontact
"
,
$
.
proxy
(
function
()
{
it
(
"
Mutual subscription between the users and a c
ontact
"
,
$
.
proxy
(
function
()
{
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
...
...
@@ -154,7 +154,7 @@
'
subscription
'
:
'
none
'
,
'
name
'
:
'
contact@example.org
'
});
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
/*
/*
* <iq type='result' id='set1'/>
*/
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
iq_id
});
...
...
@@ -243,7 +243,7 @@
/* The user's server MUST initiate a roster push to all of the user's
* available resources that have requested the roster,
* containing an updated roster item for the contact with
* the 'subscription' attribute set to a value of "to";
* the 'subscription' attribute set to a value of "to";
*
* <iq type='set'>
* <query xmlns='jabber:iq:roster'>
...
...
@@ -279,7 +279,7 @@
expect
(
$contacts
.
length
).
toBe
(
1
);
// Check that it has the right classes and text
expect
(
$contacts
.
hasClass
(
'
to
'
)).
toBeTruthy
();
expect
(
$contacts
.
hasClass
(
'
from
'
)).
toBeFalsy
();
expect
(
$contacts
.
hasClass
(
'
both
'
)).
toBeFalsy
();
expect
(
$contacts
.
hasClass
(
'
current-xmpp-contact
'
)).
toBeTruthy
();
expect
(
$contacts
.
text
().
trim
()).
toBe
(
'
Contact
'
);
expect
(
contact
.
get
(
'
chat_status
'
)).
toBe
(
'
offline
'
);
...
...
@@ -301,15 +301,53 @@
*
* <presence from='contact@example.org' to='user@example.com' type='subscribe'/>
*/
// TODO
spyOn
(
contact
,
'
authorize
'
).
andCallThrough
();
spyOn
(
this
.
roster
,
'
handleIncomingSubscription
'
).
andCallThrough
();
stanza
=
$pres
({
'
to
'
:
converse
.
bare_jid
,
'
from
'
:
'
contact@example.org/resource
'
,
'
type
'
:
'
subscribe
'
});
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
this
.
roster
.
handleIncomingSubscription
).
toHaveBeenCalled
();
/* The user's client MUST send a presence stanza of type
* "subscribed" to the contact in order to approve the
* subscription request.
*
*
* <presence to='contact@example.org' type='subscribed'/>
*/
// TODO
expect
(
contact
.
authorize
).
toHaveBeenCalled
();
expect
(
sentStanza
.
toLocaleString
()).
toBe
(
"
<presence to='contact@example.org' type='subscribed' xmlns='jabber:client'/>
"
);
/* As a result, the user's server MUST initiate a
* roster push containing a roster item for the
* contact with the 'subscription' attribute set to
* a value of "both".
*
* <iq type='set'>
* <query xmlns='jabber:iq:roster'>
* <item
* jid='contact@example.org'
* subscription='both'
* name='MyContact'>
* <group>MyBuddies</group>
* </item>
* </query>
* </iq>
*/
stanza
=
$iq
({
'
type
'
:
'
set
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
contact@example.org
'
,
'
subscription
'
:
'
both
'
,
'
name
'
:
'
contact@example.org
'
});
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
converse
.
roster
.
updateContact
).
toHaveBeenCalled
();
// The class on the contact will now have switched.
expect
(
$contacts
.
hasClass
(
'
to
'
)).
toBeFalsy
();
expect
(
$contacts
.
hasClass
(
'
both
'
)).
toBeTruthy
();
},
this
));
},
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