From: Timo Tijhof Date: Tue, 11 Jul 2017 20:05:17 +0000 (-0700) Subject: mediawiki.toc: Migrate test from deprecated asyncTest() X-Git-Tag: 1.31.0-rc.0~2709 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=6fd5e71ef9bfe940ae666dbd300c301b5299fab1 mediawiki.toc: Migrate test from deprecated asyncTest() Instead, use assert.async(), or (in this case) return the Promise directly to QUnit.test, which will naturally await it. As bonus, it'll handle errors, too. (instead of timing out) Change-Id: I94ee0bf72a3d8ac2e588cd75cbe0787b5001d5b4 --- diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index 477550bd4b..b20b68f5d6 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -6,7 +6,7 @@ } } ) ); - QUnit.asyncTest( 'toggleToc', function ( assert ) { + QUnit.test( 'toggleToc', function ( assert ) { var tocHtml, $toc, $toggleLink, $tocList; assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' ); @@ -29,13 +29,11 @@ assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' ); $toggleLink.click(); - $tocList.promise().done( function () { + return $tocList.promise().then( function () { assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' ); $toggleLink.click(); - $tocList.promise().done( function () { - QUnit.start(); - } ); + return $tocList.promise(); } ); } ); }( mediaWiki, jQuery ) );