2 QUnit
.module( 'mediawiki.toc', QUnit
.newMwEnvironment( {
4 // Prevent live cookies like mw_hidetoc=1 from interferring with the test
5 this.stub( $, 'cookie' ).returns( null );
9 QUnit
.asyncTest( 'toggleToc', 4, function ( assert
) {
10 var tocHtml
, $toggleLink
, $tocList
;
12 assert
.strictEqual( $( '#toc' ).length
, 0, 'There is no table of contents on the page at the beginning' );
14 tocHtml
= '<div id="toc" class="toc">' +
15 '<div id="toctitle">' +
18 '<ul><li></li></ul>' +
20 $( tocHtml
).appendTo( '#qunit-fixture' );
21 mw
.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
23 $tocList
= $( '#toc ul:first' );
24 $toggleLink
= $( '#togglelink' );
26 assert
.strictEqual( $toggleLink
.length
, 1, 'Toggle link is added to the table of contents' );
28 assert
.strictEqual( $tocList
.is( ':hidden' ), false, 'The table of contents is now visible' );
31 $tocList
.promise().done( function () {
32 assert
.strictEqual( $tocList
.is( ':hidden' ), true, 'The table of contents is now hidden' );
35 $tocList
.promise().done( function () {
40 }( mediaWiki
, jQuery
) );