Commit ecdb3a12 authored by JC Brand's avatar JC Brand

Merge image loading tests. Updates #814

parent 0b50c0c8
...@@ -1215,16 +1215,14 @@ ...@@ -1215,16 +1215,14 @@
})); }));
it("will render images from their URLs", mock.initConverse(function (_converse) { it("will render images from their URLs", mock.initConverse(function (_converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
if (/PhantomJS/.test(window.navigator.userAgent)) { if (/PhantomJS/.test(window.navigator.userAgent)) {
// Doesn't work when running tests in PhantomJS, since // Doesn't work when running tests in PhantomJS, since
// the page is loaded via file:/// // the page is loaded via file:///
return; return;
} }
var message = document.URL.split(window.location.pathname)[0] + "/logo/conversejs.svg"; test_utils.createContacts(_converse, 'current');
var base_url = document.URL.split(window.location.pathname)[0];
var message = base_url+"/logo/conversejs.svg";
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, contact_jid); test_utils.openChatBoxFor(_converse, contact_jid);
var view = _converse.chatboxviews.get(contact_jid); var view = _converse.chatboxviews.get(contact_jid);
...@@ -1237,33 +1235,15 @@ ...@@ -1237,33 +1235,15 @@
expect(view.sendMessage).toHaveBeenCalled(); expect(view.sendMessage).toHaveBeenCalled();
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content'); var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
expect(msg.html()).toEqual('<img src="'+message+'" class="chat-image">'); expect(msg.html()).toEqual('<img src="'+message+'" class="chat-image">');
});
}));
it("will render images from their URLs with query strings containing HTML-escaping characters", mock.initConverse(function (_converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
if (/PhantomJS/.test(window.navigator.userAgent)) { message += "?param1=val1&param2=val2";
// Doesn't work when running tests in PhantomJS, since
// the page is loaded via file:///
return;
}
var message = document.URL.split(window.location.pathname)[0] + "/logo/conversejs.svg?param1=val1&param2=val2",
htmlEscapedMessage = message.replace(/&/g, '&amp;');
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, contact_jid);
var view = _converse.chatboxviews.get(contact_jid);
spyOn(view, 'sendMessage').andCallThrough();
runs(function () {
test_utils.sendMessage(view, message); test_utils.sendMessage(view, message);
}); });
waits(500); waits(500);
runs(function () { runs(function () {
expect(view.sendMessage).toHaveBeenCalled(); expect(view.sendMessage).toHaveBeenCalled();
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content'); var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
expect(msg.html()).toEqual('<img src="'+htmlEscapedMessage+'" class="chat-image">'); expect(msg.html()).toEqual('<img src="'+message.replace(/&/g, '&amp;')+'" class="chat-image">');
}); });
})); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment