From: MatmaRex Date: Sun, 21 Jul 2013 11:40:52 +0000 (+0200) Subject: jquery.makeCollapsible: Tests for collapse and expand text X-Git-Tag: 1.31.0-rc.0~19031^2~2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=0fc0049a54d55d17b6351e310935dc962d0c92d9;p=lhc%2Fweb%2Fwiklou.git jquery.makeCollapsible: Tests for collapse and expand text Provided via data- attributes (data-collapsetext, data-expandtext) and via options (options.collapseText, options.expandText). Change-Id: I8922b80ee9aff149a56c9ca44edc247033fc6d6a --- diff --git a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js index 7ae743c0aa..38063e6838 100644 --- a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js @@ -137,4 +137,41 @@ assert.assertTrue( $content.is( ':hidden' ), 'click event on non-link inside toggle toggles content' ); } ); + QUnit.asyncTest( 'collapse/expand text (data-collapsetext, data-expandtext)', 2, function ( assert ) { + var $collapsible, $toggleLink; + $collapsible = prepareCollapsible( + '
' + + loremIpsum + + '
' + ); + $toggleLink = $collapsible.find( '.mw-collapsible-toggle a' ); + + assert.equal( $toggleLink.text(), 'Collapse me!', 'data-collapsetext is respected' ); + + $collapsible.on( 'afterCollapse.mw-collapsible', function () { + assert.equal( $toggleLink.text(), 'Expand me!', 'data-expandtext is respected' ); + QUnit.start(); + } ); + + $collapsible.find( '.mw-collapsible-toggle' ).trigger( 'click' ); + } ); + + QUnit.asyncTest( 'collapse/expand text (options.collapseText, options.expandText)', 2, function ( assert ) { + var $collapsible, $toggleLink; + $collapsible = prepareCollapsible( + '
' + loremIpsum + '
', + { collapseText: 'Collapse me!', expandText: 'Expand me!' } + ); + $toggleLink = $collapsible.find( '.mw-collapsible-toggle a' ); + + assert.equal( $toggleLink.text(), 'Collapse me!', 'options.collapseText is respected' ); + + $collapsible.on( 'afterCollapse.mw-collapsible', function () { + assert.equal( $toggleLink.text(), 'Expand me!', 'options.expandText is respected' ); + QUnit.start(); + } ); + + $collapsible.find( '.mw-collapsible-toggle' ).trigger( 'click' ); + } ); + }( mediaWiki, jQuery ) );