Merge "Align image frame padding with core"
[mediawiki.git] / tests / qunit / suites / resources / mediawiki / mediawiki.toc.test.js
blobe43516b0f2192720f30eebe598c3720988928d35
1 ( function ( mw, $ ) {
2         QUnit.module( 'mediawiki.toc', QUnit.newMwEnvironment( {
3                 setup: function () {
4                         // Prevent live cookies like mw_hidetoc=1 from interferring with the test
5                         this.stub( $, 'cookie' ).returns( null );
6                 }
7         } ) );
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">' +
16                         '<h2>Contents</h2>' +
17                         '</div>' +
18                         '<ul><li></li></ul>' +
19                         '</div>';
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' );
30                 $toggleLink.click();
31                 $tocList.promise().done( function () {
32                         assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
34                         $toggleLink.click();
35                         $tocList.promise().done( function () {
36                                 QUnit.start();
37                         } );
38                 } );
39         } );
40 }( mediaWiki, jQuery ) );