describe('jQuery plugins', function () { describe('fiveui.jquery.hasText', function () { it('finds an element containing "text foo bar"', function () { var $t = $('
text foo bar
'); expect($t.hasText('text foo bar').length).toEqual(1); }); it('finds no element containing "quux"', function () { var $t = $('
text foo bar
'); expect($t.hasText('quux').length).toEqual(0); }); it('finds a nested element containing "hobbit"', function () { $t = $('

golum

hobbit
'); expect($t.hasText('hobbit').length).toEqual(1); }); }); describe('fiveui.jquery.noAttr', function () { it('returns elements having no summary attribute', function () { var $t = $('
').noAttr('summary'); expect($t.length).toEqual(1); }); it('returns no elements on empty input', function () { var $t = $('').noAttr('summary'); expect($t.length).toEqual(0); }); it('doesn\'t return elements with attributes other than the given', function () { var $t = $('
').noAttr('summary'); expect($t.length).toEqual(1); }); it('returns multiple elements having no summary attribute', function () { var htm = '
' + '
' + '
' + '
' + '
'; var $t = $(htm).noAttr('summary'); expect($t.length).toEqual(3); }); }); describe('fiveui.jquery.noSubElt', function () { var $t = $('

red hering

blue hering

') it('filters out elements with a sub-heading', function () { expect($t.noSubElt('h1').length).toEqual(0); expect($t.noSubElt(':header').length).toEqual(0); }); it('filters out elements with a

', function () { expect($t.noSubElt('p').length).toEqual(0); }); it('retains elements without

  • ', function () { expect($t.noSubElt('li').length).toEqual(1); }); it('accepts arbitrary jQuery seclectors', function () { expect($t.noSubElt('p[name=bob]').length).toEqual(1); }); }); describe('fiveui.jquery.notColorSet', function () { var htm = '

    foo

    ' + '

    foo

    ' + '

    foo

    ' + '

    foo

    '; var $t = $(htm); it('filters out black', function () { expect($t.notColorSet(['#000000']).length).toEqual(3); }); it('filters out white', function () { expect($t.notColorSet(['#ffffff']).length).toEqual(2); }); it('filters out black and white', function () { expect($t.notColorSet(['#ffffff', '#000000']).length).toEqual(1); }); it('filters out everything', function () { expect($t.notColorSet(['#ffffff', '#000000', '#e1e1e1']).length).toEqual(0); }); }); describe('fiveui.jquery.cssIsNot', function () { var htm = '

    foo

    ' + '

    foo

    ' + '

    foo

    ' + '

    foo

    ' + '

    big

    '; var $t = $(htm); it('filters out colors', function () { expect($t.cssIsNot('color', ['#ffffff', '#000000'], fiveui.color.colorToHexWithDefault).length).toEqual(1); }); it('filters out background-colors', function () { expect($t.cssIsNot('background-color', ['#141414', '#232323'], fiveui.color.colorToHexWithDefault).length).toEqual(3); }); it('filters out elements of different type', function () { expect($t.cssIsNot('font-size', ['5em']).length).toEqual(3); }); }); describe('fiveui.jquery.linksTo', function () { it('filters out elements with no href', function () { expect($('

    foo

    ').linksTo('bar').length).toEqual(0); }); it('filters out elements with wrong href', function () { expect($('foo').linksTo('bar').length).toEqual(0); }); var htm = 'foo foo2 foo3'; var $t = $(htm); it('filters in among various hrefs', function () { expect($t.linksTo('bar').length).toEqual(1); }); it('filters out among various hrefs', function () { expect($t.linksTo('quux').length).toEqual(2); }); }); });