Update spec to test sent out stanza as well
This commit is contained in:
parent
1e5b6243be
commit
e630339a69
3931
package-lock.json
generated
3931
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -76,5 +76,7 @@
|
|||||||
"wait-until-promise": "^1.0.0",
|
"wait-until-promise": "^1.0.0",
|
||||||
"xss": "^0.3.3"
|
"xss": "^0.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"npm": "^5.7.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3142,26 +3142,41 @@
|
|||||||
null, ['rosterGroupsFetched'], {},
|
null, ['rosterGroupsFetched'], {},
|
||||||
function (done, _converse) {
|
function (done, _converse) {
|
||||||
|
|
||||||
|
var sendIQ = _converse.connection.sendIQ;
|
||||||
|
var sent_stanza, IQ_id;
|
||||||
|
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
||||||
|
sent_stanza = iq;
|
||||||
|
IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
||||||
|
});
|
||||||
|
|
||||||
test_utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
var panel = _converse.chatboxviews.get('controlbox').roomspanel;
|
var panel = _converse.chatboxviews.get('controlbox').roomspanel;
|
||||||
$(panel.tabs).find('li').last().find('a')[0].click(); // Click the chatrooms tab
|
$(panel.tabs).find('li').last().find('a')[0].click(); // Click the chatrooms tab
|
||||||
panel.model.set({'muc_domain': 'muc.localhost'}); // Make sure the domain is set
|
panel.model.set({'muc_domain': 'muc.localhost'}); // Make sure the domain is set
|
||||||
// See: http://xmpp.org/extensions/xep-0045.html#disco-rooms
|
// See: http://xmpp.org/extensions/xep-0045.html#disco-rooms
|
||||||
expect($('#available-chatrooms').children('dt').length).toBe(0);
|
expect(document.querySelectorAll('#available-chatrooms dt').length).toBe(0);
|
||||||
expect($('#available-chatrooms').children('dd').length).toBe(0);
|
expect(document.querySelectorAll('#available-chatrooms dd').length).toBe(0);
|
||||||
|
document.querySelector('input#show-rooms').click();
|
||||||
|
|
||||||
|
expect(sent_stanza.toLocaleString()).toBe(
|
||||||
|
"<iq to='muc.localhost' from='dummy@localhost/resource' type='get' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
||||||
|
"<query xmlns='http://jabber.org/protocol/disco#items'/>"+
|
||||||
|
"</iq>"
|
||||||
|
);
|
||||||
|
|
||||||
var iq = $iq({
|
var iq = $iq({
|
||||||
from:'muc.localhost',
|
from:'muc.localhost',
|
||||||
to:'dummy@localhost/pda',
|
to:'dummy@localhost/pda',
|
||||||
|
id: IQ_id,
|
||||||
type:'result'
|
type:'result'
|
||||||
}).c('query')
|
}).c('query')
|
||||||
.c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up()
|
.c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up()
|
||||||
.c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up()
|
.c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up()
|
||||||
.c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up()
|
.c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up()
|
||||||
.c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth's Castle'}).nodeTree;
|
.c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth's Castle'}).nodeTree;
|
||||||
|
_converse.connection._dataRecv(test_utils.createRequest(iq));
|
||||||
|
|
||||||
panel.onRoomsFound(iq);
|
expect(document.querySelectorAll('#available-chatrooms dt').length).toBe(1);
|
||||||
expect($(panel.el.querySelector('#available-chatrooms')).children('dt').length).toBe(1);
|
|
||||||
expect($(panel.el.querySelector('#available-chatrooms')).children('dt').first().text()).toBe("Rooms found");
|
expect($(panel.el.querySelector('#available-chatrooms')).children('dt').first().text()).toBe("Rooms found");
|
||||||
expect($(panel.el.querySelector('#available-chatrooms')).children('dd').length).toBe(4);
|
expect($(panel.el.querySelector('#available-chatrooms')).children('dd').length).toBe(4);
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user