Merge "JSON i18n shim: Only register LocalisationCacheRecache handler once"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.toc.test.js
1 ( function ( mw, $ ) {
2 QUnit.module( 'mediawiki.toc', QUnit.newMwEnvironment() );
3
4 QUnit.asyncTest( 'toggleToc', 4, function ( assert ) {
5 var tocHtml, $toggleLink, $tocList;
6
7 assert.strictEqual( $( '#toc' ).length, 0, 'There is no table of contents on the page at the beginning' );
8
9 tocHtml = '<div id="toc" class="toc">' +
10 '<div id="toctitle">' +
11 '<h2>Contents</h2>' +
12 '</div>' +
13 '<ul><li></li></ul>' +
14 '</div>';
15 $( tocHtml ).appendTo( '#qunit-fixture' );
16 mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
17
18 $tocList = $( '#toc ul:first' );
19 $toggleLink = $( '#togglelink' );
20
21 assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' );
22
23 assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' );
24
25 $toggleLink.click();
26 $tocList.promise().done( function () {
27 assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
28
29 $toggleLink.click();
30 $tocList.promise().done( function () {
31 QUnit.start();
32 } );
33 } );
34 } );
35 }( mediaWiki, jQuery ) );