mediawiki.toc.test: Stub $.cookie to avoid test pollution
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 20 May 2014 14:40:55 +0000 (16:40 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 20 May 2014 14:41:35 +0000 (16:41 +0200)
When running the tests locally the mediawiki.toc tests often
fail because where it asserts hidden it is visible, and where it
asserts visible it is hidden (this happens if you've ever closed
a "toc" section on your local wiki, causes the tests to be one-off).

Change-Id: Idc5e7123f3be3e11dac50d76d13089a2fabcfdb5

tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js

index 3f856b9..e43516b 100644 (file)
@@ -1,5 +1,10 @@
 ( function ( mw, $ ) {
-       QUnit.module( 'mediawiki.toc', QUnit.newMwEnvironment() );
+       QUnit.module( 'mediawiki.toc', QUnit.newMwEnvironment( {
+               setup: function () {
+                       // Prevent live cookies like mw_hidetoc=1 from interferring with the test
+                       this.stub( $, 'cookie' ).returns( null );
+               }
+       } ) );
 
        QUnit.asyncTest( 'toggleToc', 4, function ( assert ) {
                var tocHtml, $toggleLink, $tocList;