(function (root, factory) { define(["jquery", "jasmine", "mock", "converse-core", "test-utils"], factory); } (this, function ($, jasmine, mock, converse, test_utils) { var _ = converse.env._; var $pres = converse.env.$pres; var $msg = converse.env.$msg; var $iq = converse.env.$iq; var u = converse.env.utils; var checkHeaderToggling = function ($group) { var $toggle = $group.find('a.group-toggle'); expect(u.isVisible($group[0])).toBeTruthy(); expect($group.find('ul.collapsed').length).toBe(0); expect($toggle.hasClass('icon-closed')).toBeFalsy(); expect($toggle.hasClass('icon-opened')).toBeTruthy(); $toggle[0].click(); return test_utils.waitUntil(function () { return $group.find('ul.collapsed').length === 1; }, 500).then(function () { expect($toggle.hasClass('icon-closed')).toBeTruthy(); expect($toggle.hasClass('icon-opened')).toBeFalsy(); $toggle[0].click(); return test_utils.waitUntil(function () { return $group.find('li').length === $group.find('li:visible').length }, 500); }).then(function () { expect($toggle.hasClass('icon-closed')).toBeFalsy(); expect($toggle.hasClass('icon-opened')).toBeTruthy(); }); }; describe("The Contacts Roster", function () { describe("The live filter", function () { it("will only appear when roster contacts flow over the visible area", mock.initConverseWithPromises( null, ['rosterGroupsFetched'], {}, function (done, _converse) { var $filter = _converse.rosterview.$('.roster-filter'); var names = mock.cur_names; test_utils.openControlBox(); _converse.rosterview.update(); // XXX: Will normally called as event handler expect($filter.length).toBe(1); test_utils.waitUntil(function () { return !$filter.is(':visible'); }).then(function () { for (var i=0; i