Parcourir la source

Fix failing test

JC Brand il y a 7 ans
Parent
commit
7c782ed6a4
2 fichiers modifiés avec 42 ajouts et 40 suppressions
  1. 40 38
      spec/chatroom.js
  2. 2 2
      tests/utils.js

+ 40 - 38
spec/chatroom.js

@@ -1671,46 +1671,48 @@
 
                 var sent_IQ, IQ_id;
                 var sendIQ = _converse.connection.sendIQ;
-                spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
-                    sent_IQ = iq;
-                    IQ_id = sendIQ.bind(this)(iq, callback, errback);
-                });
-                _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'});
 
-                // We pretend this is a new room, so no disco info is returned.
-                var features_stanza = $iq({
-                        from: 'coven@chat.shakespeare.lit',
-                        'id': IQ_id,
-                        'to': 'dummy@localhost/desktop',
-                        'type': 'error'
-                    }).c('error', {'type': 'cancel'})
-                        .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
-                _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
+                test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'some1').then(function () {
+                    spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
+                        sent_IQ = iq;
+                        IQ_id = sendIQ.bind(this)(iq, callback, errback);
+                    });
 
-                var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
-                /* <message xmlns="jabber:client"
-                 *              type="groupchat"
-                 *              to="dummy@localhost/_converse.js-27854181"
-                 *              from="coven@chat.shakespeare.lit">
-                 *      <x xmlns="http://jabber.org/protocol/muc#user">
-                 *          <status code="104"/>
-                 *          <status code="172"/>
-                 *      </x>
-                 *  </message>
-                 */
-                var message = $msg({
-                        type:'groupchat',
-                        to: 'dummy@localhost/_converse.js-27854181',
-                        from: 'coven@chat.shakespeare.lit'
-                    }).c('x', {xmlns: Strophe.NS.MUC_USER})
-                      .c('status', {code: '104'}).up()
-                      .c('status', {code: '172'});
-                _converse.connection._dataRecv(test_utils.createRequest(message));
-                var $chat_body = view.$('.chatroom-body');
-                expect($chat_body.html().trim().indexOf(
-                    '<div class="chat-info">This room is now no longer anonymous</div>'
-                )).not.toBe(-1);
-                done();
+                    // We pretend this is a new room, so no disco info is returned.
+                    var features_stanza = $iq({
+                            from: 'coven@chat.shakespeare.lit',
+                            'id': IQ_id,
+                            'to': 'dummy@localhost/desktop',
+                            'type': 'error'
+                        }).c('error', {'type': 'cancel'})
+                            .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
+                    _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
+
+                    var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
+                    /* <message xmlns="jabber:client"
+                    *              type="groupchat"
+                    *              to="dummy@localhost/_converse.js-27854181"
+                    *              from="coven@chat.shakespeare.lit">
+                    *      <x xmlns="http://jabber.org/protocol/muc#user">
+                    *          <status code="104"/>
+                    *          <status code="172"/>
+                    *      </x>
+                    *  </message>
+                    */
+                    var message = $msg({
+                            type:'groupchat',
+                            to: 'dummy@localhost/_converse.js-27854181',
+                            from: 'coven@chat.shakespeare.lit'
+                        }).c('x', {xmlns: Strophe.NS.MUC_USER})
+                        .c('status', {code: '104'}).up()
+                        .c('status', {code: '172'});
+                    _converse.connection._dataRecv(test_utils.createRequest(message));
+                    var $chat_body = view.$('.chatroom-body');
+                    expect($chat_body.html().trim().indexOf(
+                        '<div class="message chat-info">This room is now no longer anonymous</div>'
+                    )).not.toBe(-1);
+                    done();
+                });
             }));
 
             it("informs users if they have been kicked out of the chat room",

+ 2 - 2
tests/utils.js

@@ -120,9 +120,9 @@
             // We pretend this is a new room, so no disco info is returned.
             var IQ_id = converse.connection.sendIQ.firstCall.returnValue;
             var features_stanza = $iq({
-                    'from': 'lounge@localhost',
+                    'from': room+'@'+server,
                     'id': IQ_id,
-                    'to': 'dummy@localhost/desktop',
+                    'to': nick+'@'+server+'/desktop',
                     'type': 'error'
                 }).c('error', {'type': 'cancel'})
                     .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});