Commit 713e49b0 authored by JC Brand's avatar JC Brand

Fix failing tests

parent f84790e6
......@@ -3,6 +3,7 @@
} (this, function ($, jasmine, mock, converse, test_utils) {
"use strict";
var _ = converse.env._;
var Backbone = converse.env.Backbone;
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
var $msg = converse.env.$msg;
......@@ -371,7 +372,7 @@
spyOn(_converse, 'onMAMPreferences').and.callThrough();
_converse.message_archiving = 'never';
var feature = new _converse.Feature({
var feature = new Backbone.Model({
'var': Strophe.NS.MAM
});
spyOn(feature, 'save').and.callFake(feature.set); // Save will complain about a url not being set
......
......@@ -73,15 +73,20 @@
panel.delegateEvents(); // Rebind all events so that our spy gets called
/* Add a new contact through the UI */
var $form = panel.$('form.add-xmpp-contact');
expect($form.is(":visible")).toBeFalsy();
var form = panel.el.querySelector('form.add-xmpp-contact');
expect(_.isNull(form)).toBeTruthy();
// Click the "Add a contact" link.
panel.$('.toggle-xmpp-contact-form').click();
// Check that the $form appears
expect($form.is(":visible")).toBeTruthy();
// Check that the form appears
form = panel.el.querySelector('form.add-xmpp-contact');
expect(form.parentElement.offsetHeight).not.toBe(0);
expect(_.includes(form.parentElement.classList, 'collapsed')).toBeFalsy();
// Fill in the form and submit
$form.find('input').val('contact@example.org');
$form.submit();
$(form).find('input').val('contact@example.org');
$(form).submit();
/* In preparation for being able to render the contact in the
* user's client interface and for the server to keep track of the
......@@ -91,8 +96,11 @@
expect(panel.addContactFromForm).toHaveBeenCalled();
expect(_converse.roster.addAndSubscribe).toHaveBeenCalled();
expect(_converse.roster.addContact).toHaveBeenCalled();
// The form should not be visible anymore.
expect($form.is(":visible")).toBeFalsy();
// The form should not be visible anymore (by virtue of its
// parent being collapsed)
expect(form.parentElement.offsetHeight).toBe(0);
expect(_.includes(form.parentElement.classList, 'collapsed')).toBeTrue;
/* _converse request consists of sending an IQ
* stanza of type='set' containing a <query/> element qualified by
......@@ -175,7 +183,7 @@
test_utils.waitUntil(function () {
return sent_stanzas.length == 1;
}).then(function () {
}, 300).then(function () {
expect(contact.subscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
......@@ -216,7 +224,8 @@
// contact in the roster.
test_utils.waitUntil(function () {
return $('a:contains("Pending contacts")').length;
}).then(function () {
}, 300).then(function () {
var $header = $('a:contains("Pending contacts")');
expect($header.length).toBe(1);
expect($header.is(":visible")).toBeTruthy();
......
......@@ -273,7 +273,8 @@
} else if (_.includes(el.classList, 'collapsed')) {
return resolve();
} else if ($.fx.off) { // Effects are disabled (for tests)
el.style.height = 0 + 'px';
el.classList.add('collapsed');
el.style.height = "";
return resolve();
}
let interval_marker = el.getAttribute('data-slider-marker');
......@@ -292,10 +293,10 @@
if (h > 0) {
el.style.height = h + 'px';
} else {
el.removeAttribute('data-slider-marker');
window.clearInterval(interval_marker);
el.classList.add('collapsed');
el.style.height = "";
window.clearInterval(interval_marker);
el.removeAttribute('data-slider-marker');
resolve();
}
}, interval);
......
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