Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/365688 )

Change subject: qunit: Add testrunner tests for nested modules and 
before/afterEach
......................................................................

qunit: Add testrunner tests for nested modules and before/afterEach

* Nested modules: Fixed by Ib17bbbef45b2bd.

* beforeEach/afterEach: Currently broken because our QUnit.module() wrapper
  registers setup/teardown, which shadows before/afterEach.

Change-Id: If4141df10eae55cbe8a5ca7a26707be1cd7b9217
---
M tests/qunit/data/testrunner.js
1 file changed, 31 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/88/365688/1

diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js
index f023ddd..a106ae2 100644
--- a/tests/qunit/data/testrunner.js
+++ b/tests/qunit/data/testrunner.js
@@ -435,7 +435,7 @@
         * Small test suite to confirm proper functionality of the utilities and
         * initializations defined above in this file.
         */
-       QUnit.module( 'test.mediawiki.qunit.testrunner', 
QUnit.newMwEnvironment( {
+       QUnit.module( 'testrunner', QUnit.newMwEnvironment( {
                setup: function () {
                        this.mwHtmlLive = mw.html;
                        mw.html = {
@@ -488,7 +488,7 @@
                assert.deepEqual( missing, [], 'Modules in missing state' );
        } );
 
-       QUnit.test( 'htmlEqual', function ( assert ) {
+       QUnit.test( 'assert.htmlEqual', function ( assert ) {
                assert.htmlEqual(
                        '<div><p class="some classes" data-length="10">Child 
paragraph with <a href="http://example.com";>A link</a></p>Regular text<span>A 
span</span></div>',
                        '<div><p data-length=\'10\'  class=\'some 
classes\'>Child paragraph with <a href=\'http://example.com\' >A 
link</a></p>Regular text<span>A span</span></div>',
@@ -538,7 +538,7 @@
 
        } );
 
-       QUnit.module( 'test.mediawiki.qunit.testrunner-after', 
QUnit.newMwEnvironment() );
+       QUnit.module( 'testrunner-after', QUnit.newMwEnvironment() );
 
        QUnit.test( 'Teardown', function ( assert ) {
                assert.equal( mw.html.escape( '<' ), '&lt;', 'teardown() 
callback was ran.' );
@@ -546,4 +546,32 @@
                assert.equal( mw.messages.get( 'testMsg' ), null, 'messages 
object restored to live in next module()' );
        } );
 
+       QUnit.module( 'testrunner-each', {
+               beforeEach: function () {
+                       this.mwHtmlLive = mw.html;
+               },
+               afterEach: function () {
+                       mw.html = this.mwHtmlLive;
+               }
+       } );
+
+       QUnit.test( 'beforeEach', function ( assert ) {
+               assert.ok( this.mwHtmlLive, 'beforeEach() ran' );
+               mw.html = null;
+       } );
+
+       QUnit.test( 'afterEach', function ( assert ) {
+               assert.equal( mw.html.escape( '<' ), '&lt;', 'afterEach() ran' 
);
+       } );
+
+       // Regression test for 'this.sandbox undefined' error, fixed by
+       // ensuring Sinon setup/teardown is not re-run on inner module.
+       QUnit.module( 'testrunner-nested', function () {
+               QUnit.module( 'testrunner-nested-inner', function () {
+                       QUnit.test( 'Dummy', function ( assert ) {
+                               assert.ok( true, 'Nested modules supported' );
+                       } );
+               } );
+       } );
+
 }( jQuery, mediaWiki, QUnit ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/365688
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4141df10eae55cbe8a5ca7a26707be1cd7b9217
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to