2 QUnit
.module( 'mediawiki.toc', QUnit
.newMwEnvironment() );
4 QUnit
.asyncTest( 'toggleToc', 4, function ( assert
) {
5 var tocHtml
, $toggleLink
, $tocList
;
7 assert
.strictEqual( $( '#toc' ).length
, 0, 'There is no table of contents on the page at the beginning' );
9 tocHtml
= '<div id="toc" class="toc">' +
10 '<div id="toctitle">' +
13 '<ul><li></li></ul>' +
15 $( tocHtml
).appendTo( '#qunit-fixture' );
16 mw
.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
18 $tocList
= $( '#toc ul:first' );
19 $toggleLink
= $( '#togglelink' );
21 assert
.strictEqual( $toggleLink
.length
, 1, 'Toggle link is added to the table of contents' );
23 assert
.strictEqual( $tocList
.is( ':hidden' ), false, 'The table of contents is now visible' );
26 $tocList
.promise().done( function () {
27 assert
.strictEqual( $tocList
.is( ':hidden' ), true, 'The table of contents is now hidden' );
30 $tocList
.promise().done( function () {
35 }( mediaWiki
, jQuery
) );