Merge "Add 3D filetype for STL files"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.toc.test.js
1 ( function ( mw, $ ) {
2 QUnit.module( 'mediawiki.toc', QUnit.newMwEnvironment( {
3 setup: function () {
4 // Prevent live cookies from interferring with the test
5 this.stub( $, 'cookie' ).returns( null );
6 }
7 } ) );
8
9 QUnit.asyncTest( 'toggleToc', function ( assert ) {
10 var tocHtml, $toc, $toggleLink, $tocList;
11
12 assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' );
13
14 tocHtml = '<div id="toc" class="toc">' +
15 '<div class="toctitle">' +
16 '<h2>Contents</h2>' +
17 '</div>' +
18 '<ul><li></li></ul>' +
19 '</div>';
20 $toc = $( tocHtml );
21 $( '#qunit-fixture' ).append( $toc );
22 mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
23
24 $tocList = $toc.find( 'ul:first' );
25 $toggleLink = $toc.find( '.togglelink' );
26
27 assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' );
28
29 assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' );
30
31 $toggleLink.click();
32 $tocList.promise().done( function () {
33 assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
34
35 $toggleLink.click();
36 $tocList.promise().done( function () {
37 QUnit.start();
38 } );
39 } );
40 } );
41 }( mediaWiki, jQuery ) );