diff --git a/spec/protocol.js b/spec/protocol.js
index 3af3fda63..8588f8b97 100644
--- a/spec/protocol.js
+++ b/spec/protocol.js
@@ -54,7 +54,7 @@
test_utils.openContactsPanel();
});
- it("User Subscribes to Contact", $.proxy(function () {
+ it("Mutual subscription between the users and a contact", $.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));
- /*
+ /*
*
*/
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";
*
*
*
@@ -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 @@
*
*
*/
- // 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.
- *
+ *
*
*/
- // TODO
+ expect(contact.authorize).toHaveBeenCalled();
+ expect(sentStanza.toLocaleString()).toBe(
+ ""
+ );
+
+ /* 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".
+ *
+ *
+ *
+ * -
+ * MyBuddies
+ *
+ *
+ *
+ */
+ 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));