Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[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, $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 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' ) );
22
23 $tocList = $( '#toc ul:first' );
24 $toggleLink = $( '#togglelink' );
25
26 assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' );
27
28 assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' );
29
30 $toggleLink.click();
31 $tocList.promise().done( function () {
32 assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
33
34 $toggleLink.click();
35 $tocList.promise().done( function () {
36 QUnit.start();
37 } );
38 } );
39 } );
40 }( mediaWiki, jQuery ) );