123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667 |
- describe('OCA.Files.BreadCrumb tests', function() {
- var BreadCrumb = OCA.Files.BreadCrumb;
- describe('Rendering', function() {
- var bc;
- beforeEach(function() {
- bc = new BreadCrumb({
- getCrumbUrl: function(part, index) {
-
- return part.dir + '#' + index;
- }
- });
- });
- afterEach(function() {
- bc = null;
- });
- it('Renders its own container', function() {
- bc.render();
- expect(bc.$el.find("ul").hasClass('breadcrumb')).toEqual(true);
- });
- it('Renders root by default', function() {
- var $crumbs;
- bc.render();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.length).toEqual(2);
- expect($crumbs.eq(0).find('a').hasClass('icon-more')).toEqual(true);
- expect($crumbs.eq(0).find('div.popovermenu').length).toEqual(1);
- expect($crumbs.eq(0).data('dir')).not.toBeDefined();
- expect($crumbs.eq(1).find('a').attr('href')).toEqual('/#1');
- expect($crumbs.eq(1).find('a').hasClass('icon-home')).toEqual(true);
- expect($crumbs.eq(1).data('dir')).toEqual('/');
- });
- it('Renders root when switching to root', function() {
- var $crumbs;
- bc.setDirectory('/somedir');
- bc.setDirectory('/');
- $crumbs = bc.$el.find('.crumb');
- expect($crumbs.length).toEqual(2);
- expect($crumbs.eq(1).data('dir')).toEqual('/');
- });
- it('Renders single path section', function() {
- var $crumbs;
- bc.setDirectory('/somedir');
- $crumbs = bc.$el.find('.crumb');
- expect($crumbs.length).toEqual(3);
- expect($crumbs.eq(0).find('a').hasClass('icon-more')).toEqual(true);
- expect($crumbs.eq(0).find('div.popovermenu').length).toEqual(1);
- expect($crumbs.eq(0).data('dir')).not.toBeDefined();
- expect($crumbs.eq(1).find('a').attr('href')).toEqual('/#1');
- expect($crumbs.eq(1).find('a').hasClass('icon-home')).toEqual(true);
- expect($crumbs.eq(1).data('dir')).toEqual('/');
- expect($crumbs.eq(2).find('a').attr('href')).toEqual('/somedir#2');
- expect($crumbs.eq(2).find('img').length).toEqual(0);
- expect($crumbs.eq(2).data('dir')).toEqual('/somedir');
- });
- it('Renders multiple path sections and special chars', function() {
- var $crumbs;
- bc.setDirectory('/somedir/with space/abc');
- $crumbs = bc.$el.find('.crumb');
- expect($crumbs.length).toEqual(5);
- expect($crumbs.eq(0).find('a').hasClass('icon-more')).toEqual(true);
- expect($crumbs.eq(0).find('div.popovermenu').length).toEqual(1);
- expect($crumbs.eq(0).data('dir')).not.toBeDefined();
- expect($crumbs.eq(1).find('a').attr('href')).toEqual('/#1');
- expect($crumbs.eq(1).find('a').hasClass('icon-home')).toEqual(true);
- expect($crumbs.eq(1).data('dir')).toEqual('/');
- expect($crumbs.eq(2).find('a').attr('href')).toEqual('/somedir#2');
- expect($crumbs.eq(2).find('img').length).toEqual(0);
- expect($crumbs.eq(2).data('dir')).toEqual('/somedir');
- expect($crumbs.eq(3).find('a').attr('href')).toEqual('/somedir/with space#3');
- expect($crumbs.eq(3).find('img').length).toEqual(0);
- expect($crumbs.eq(3).data('dir')).toEqual('/somedir/with space');
- expect($crumbs.eq(4).find('a').attr('href')).toEqual('/somedir/with space/abc#4');
- expect($crumbs.eq(4).find('img').length).toEqual(0);
- expect($crumbs.eq(4).data('dir')).toEqual('/somedir/with space/abc');
- });
- it('Renders backslashes as regular directory separator', function() {
- var $crumbs;
- bc.setDirectory('/somedir\\with/mixed\\separators');
- $crumbs = bc.$el.find('.crumb');
- expect($crumbs.length).toEqual(6);
- expect($crumbs.eq(0).find('a').hasClass('icon-more')).toEqual(true);
- expect($crumbs.eq(0).find('div.popovermenu').length).toEqual(1);
- expect($crumbs.eq(0).data('dir')).not.toBeDefined();
- expect($crumbs.eq(1).find('a').attr('href')).toEqual('/#1');
- expect($crumbs.eq(1).find('a').hasClass('icon-home')).toEqual(true);
- expect($crumbs.eq(1).data('dir')).toEqual('/');
- expect($crumbs.eq(2).find('a').attr('href')).toEqual('/somedir#2');
- expect($crumbs.eq(2).find('img').length).toEqual(0);
- expect($crumbs.eq(2).data('dir')).toEqual('/somedir');
- expect($crumbs.eq(3).find('a').attr('href')).toEqual('/somedir/with#3');
- expect($crumbs.eq(3).find('img').length).toEqual(0);
- expect($crumbs.eq(3).data('dir')).toEqual('/somedir/with');
- expect($crumbs.eq(4).find('a').attr('href')).toEqual('/somedir/with/mixed#4');
- expect($crumbs.eq(4).find('img').length).toEqual(0);
- expect($crumbs.eq(4).data('dir')).toEqual('/somedir/with/mixed');
- expect($crumbs.eq(5).find('a').attr('href')).toEqual('/somedir/with/mixed/separators#5');
- expect($crumbs.eq(5).find('img').length).toEqual(0);
- expect($crumbs.eq(5).data('dir')).toEqual('/somedir/with/mixed/separators');
- });
- });
- describe('Events', function() {
- it('Calls onClick handler when clicking on a crumb', function() {
- var handler = sinon.stub();
- var bc = new BreadCrumb({
- onClick: handler
- });
- bc.setDirectory('/one/two/three/four');
-
- bc.$el.find('.crumb:eq(4)').click();
- expect(handler.calledOnce).toEqual(false);
- handler.reset();
-
- bc.$el.find('.crumb:eq(1) a').click();
- expect(handler.calledOnce).toEqual(true);
- expect(handler.getCall(0).thisValue).toEqual(bc.$el.find('.crumb > a').get(1));
- });
- it('Calls onDrop handler when dropping on a crumb', function() {
- var droppableStub = sinon.stub($.fn, 'droppable');
- var handler = sinon.stub();
- var bc = new BreadCrumb({
- onDrop: handler
- });
- bc.setDirectory('/one/two/three/four');
- expect(droppableStub.calledOnce).toEqual(true);
- expect(droppableStub.getCall(0).args[0].drop).toBeDefined();
-
- droppableStub.getCall(0).args[0].drop({dummy: true});
- expect(handler.calledOnce).toEqual(true);
- expect(handler.getCall(0).args[0]).toEqual({dummy: true});
- droppableStub.restore();
- });
- });
- describe('Menu tests', function() {
- var bc, dummyDir, $crumbmenuLink, $popovermenu;
- beforeEach(function() {
- dummyDir = '/one/two/three/four/five'
- bc = new BreadCrumb();
-
-
- $('#testArea').append(
- '<div class="files-controls"></div>'
- );
- $('.files-controls').append(bc.$el);
- bc.setDirectory(dummyDir);
- $('li.crumb').each(function(index){
- $(this).css('width', 50);
- $(this).css('padding', 0);
- $(this).css('margin', 0);
- });
- $('div.crumbhome').css('width', 51);
- $('div.crumbmenu').css('width', 51);
- $('.files-controls').width(1000);
- bc._resize();
-
- $('.files-controls').width(300);
- bc._resize();
- $crumbmenuLink = bc.$el.find('.crumbmenu > a');
- $popovermenu = $crumbmenuLink.next('.popovermenu');
- });
- afterEach(function() {
- bc = null;
- });
- it('Shows only items not in the breadcrumb', function() {
- var hiddenCrumbs = bc.$el.find('.crumb:not(.crumbmenu).hidden');
- expect($popovermenu.find('li:not(.in-breadcrumb)').length).toEqual(hiddenCrumbs.length);
- });
- });
- describe('Resizing', function() {
- var bc, dummyDir, widths, paddings, margins;
-
-
- var cit = window.isPhantom?xit:it;
- beforeEach(function() {
- dummyDir = '/short name/longer name/looooooooooooonger/' +
- 'even longer long long long longer long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/last one';
- bc = new BreadCrumb();
-
-
- $('#testArea').append(
- '<div class="files-controls"></div>'
- );
- $('.files-controls').append(bc.$el);
-
- bc.setDirectory(dummyDir);
-
-
-
- widths = [51, 51, 106, 112, 160, 257, 251, 91];
-
-
- paddings = [0, 0, 0, 0, 0, 0, 0, 0];
- margins = [0, 0, 0, 0, 0, 0, 0, 0];
- $('li.crumb').each(function(index){
- $(this).css('width', widths[index]);
- $(this).css('padding', paddings[index]);
- $(this).css('margin', margins[index]);
- });
- });
- afterEach(function() {
- bc = null;
- });
- it('Hides breadcrumbs to fit available width', function() {
- var $crumbs;
- $('.files-controls').width(500);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Hides breadcrumbs to fit available width', function() {
- var $crumbs;
- $('.files-controls').width(700);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Hides breadcrumbs to fit available width taking paddings into account', function() {
- var $crumbs;
-
- paddings = [10, 10, 10, 10, 10, 10, 10, 10];
- $('li.crumb').each(function(index){
- $(this).css('padding', paddings[index]);
- });
- $('.files-controls').width(700);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Hides breadcrumbs to fit available width taking margins into account', function() {
- var $crumbs;
-
- margins = [10, 10, 10, 10, 10, 10, 10, 10];
- $('li.crumb').each(function(index){
- $(this).css('margin', margins[index]);
- });
- $('.files-controls').width(700);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Hides breadcrumbs to fit available width left by siblings', function() {
- var $crumbs;
- $('.files-controls').width(700);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
- var $previousSibling = $('<div class="otherSibling"></div>');
-
-
- $previousSibling.css('width', '50px');
- $previousSibling.css('min-width', '50px');
- $('.files-controls').prepend($previousSibling);
- var $creatableActions = $('<div class="actions creatable"></div>');
-
-
- $creatableActions.css('width', '100px');
- $creatableActions.css('min-width', '100px');
- $('.files-controls').append($creatableActions);
- var $nextHiddenSibling = $('<div class="otherSibling hidden"></div>');
-
-
- $nextHiddenSibling.css('width', '200px');
- $nextHiddenSibling.css('min-width', '200px');
- $('.files-controls').append($nextHiddenSibling);
- var $nextSibling = $('<div class="otherSibling"></div>');
-
-
- $nextSibling.css('width', '50px');
- $nextSibling.css('min-width', '50px');
- $('.files-controls').append($nextSibling);
- bc._resize();
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Hides breadcrumbs to fit available width left by siblings with paddings and margins', function() {
- var $crumbs;
- $('.files-controls').width(700);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
- var $previousSibling = $('<div class="otherSibling"></div>');
-
-
- $previousSibling.css('width', '10px');
- $previousSibling.css('min-width', '10px');
- $previousSibling.css('margin', '20px');
- $('.files-controls').prepend($previousSibling);
- var $creatableActions = $('<div class="actions creatable"></div>');
-
-
- $creatableActions.css('width', '20px');
- $creatableActions.css('min-width', '20px');
- $creatableActions.css('margin-left', '40px');
- $creatableActions.css('padding-right', '40px');
- $('.files-controls').append($creatableActions);
- var $nextHiddenSibling = $('<div class="otherSibling hidden"></div>');
-
-
- $nextHiddenSibling.css('width', '200px');
- $nextHiddenSibling.css('min-width', '200px');
- $('.files-controls').append($nextHiddenSibling);
- var $nextSibling = $('<div class="otherSibling"></div>');
-
-
- $nextSibling.css('width', '10px');
- $nextSibling.css('min-width', '10px');
- $nextSibling.css('padding', '20px');
- $('.files-controls').append($nextSibling);
- bc._resize();
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Updates the breadcrumbs when reducing available width', function() {
- var $crumbs;
-
- $('.files-controls').width(1800);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(true);
-
- $('.files-controls').width(950);
- bc._resize();
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Updates the breadcrumbs when reducing available width taking into account the menu width', function() {
- var $crumbs;
-
- $('.files-controls').width(1800);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
-
-
-
- $('.files-controls').width(650);
- bc._resize();
-
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Updates the breadcrumbs when increasing available width', function() {
- var $crumbs;
-
- $('.files-controls').width(850);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
- $('.files-controls').width(1000);
- bc._resize();
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- it('Updates the breadcrumbs when increasing available width taking into account the menu width', function() {
- var $crumbs;
-
- $('.files-controls').width(850);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
-
- $('.files-controls').width(1030);
- bc._resize();
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- cit('Updates the breadcrumbs when increasing available width with an expanding sibling', function() {
- var $crumbs;
-
- var $nextSibling = $('<div class="sibling"></div>');
-
-
- $nextSibling.css('width', '10px');
- $nextSibling.css('min-width', '10px');
- $nextSibling.css('display', 'flex');
- $nextSibling.css('flex', '1 1');
- var $nextSiblingChild = $('<div class="siblingChild"></div>');
- $nextSiblingChild.css('margin-left', 'auto');
- $nextSibling.append($nextSiblingChild);
- $('.files-controls').append($nextSibling);
-
- $('.files-controls').width(850);
- bc._resize();
- $crumbs = bc.$el.find('.crumb');
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
-
- $('.files-controls').width(1000);
- bc._resize();
-
- expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
- expect($crumbs.eq(5).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
- expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
- });
- });
- });
|