Sha256: f35e1f8d1e667af85a4ca1b32daea85b0179bf3f4b7bb03b981fa1567d37d1eb
Contents?: true
Size: 1.74 KB
Versions: 62
Compression:
Stored size: 1.74 KB
Contents
describe('primary-links', function(){ var shortList, mediumList, longList; beforeEach(function () { shortList = $('<ul><li class="primary">one</li><li>two</li></ul>'); mediumList = $('<ul><li class="primary">one</li><li>two</li><li>three</li></ul>'); longList = $('<ul><li class="primary">one</li><li class="primary">two</li><li>three</li><li>four</li></ul>'); }); it('visually hides extra links', function(){ var list = new GOVUK.PrimaryList(mediumList, '.primary'); expect(mediumList.find('.visuallyhidden').length).toBe(2); }); it('creates appropriate toggle text', function(){ var short = new GOVUK.PrimaryList(shortList, '.primary'); var medium = new GOVUK.PrimaryList(mediumList, '.primary'); expect(short.toggleText()).toEqual('+1 other'); expect(medium.toggleText()).toEqual('+2 others'); }); it('add a toggle link', function(){ var container = $('<div>').append(mediumList); var list = new GOVUK.PrimaryList(mediumList, '.primary'); expect(container.find('a').length).toBe(1); }); it('show extra links when toggled', function(){ var list = new GOVUK.PrimaryList(mediumList, '.primary'); var event = { preventDefault: function(){} }; spyOn(event, 'preventDefault'); spyOn(list, 'showExtraLinks'); list.toggleLinks(event); expect(event.preventDefault).toHaveBeenCalled(); expect(list.showExtraLinks).toHaveBeenCalled(); }); it('only adds toggle if more than one extra link', function(){ var short = new GOVUK.PrimaryList(shortList, '.primary'); var medium = new GOVUK.PrimaryList(mediumList, '.primary'); expect(shortList.find('.visuallyhidden').length).toBe(0); expect(mediumList.find('.visuallyhidden').length).toBe(2); }); });
Version data entries
62 entries across 62 versions & 1 rubygems