r112279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112278‎ | r112279 | r112280 >
Date:00:44, 24 February 2012
Author:krinkle
Status:ok
Tags:
Comment:
[JSTesting] Refactor mw.loader test to be more extendable
Modified paths:
  • /trunk/phase3/tests/qunit/data/callMwLoaderTestCallback.js (added) (history)
  • /trunk/phase3/tests/qunit/data/defineTestCallback.js (deleted) (history)
  • /trunk/phase3/tests/qunit/data/testrunner.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/data/defineTestCallback.js
@@ -1,4 +0,0 @@
2 -window.mw.loader.testCallback = function() {
3 - start();
4 - ok( true, 'Implementing a module, is the callback timed properly ?');
5 -};
Index: trunk/phase3/tests/qunit/data/testrunner.js
@@ -6,9 +6,9 @@
77 /**
88 * Add bogus to url to prevent IE crazy caching
99 *
10 - * @param value {String} a relative path (eg. 'data/defineTestCallback.js'
 10+ * @param value {String} a relative path (eg. 'data/foo.js'
1111 * or 'data/test.php?foo=bar').
12 - * @return {String} Such as 'data/defineTestCallback.js?131031765087663960'
 12+ * @return {String} Such as 'data/foo.js?131031765087663960'
1313 */
1414 QUnit.fixurl = function (value) {
1515 return value + (/\?/.test( value ) ? '&' : '?')
Index: trunk/phase3/tests/qunit/data/callMwLoaderTestCallback.js
@@ -0,0 +1 @@
 2+mw.loader.testCallback();
Property changes on: trunk/phase3/tests/qunit/data/callMwLoaderTestCallback.js
___________________________________________________________________
Added: svn:eol-style
13 + native
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
@@ -144,23 +144,31 @@
145145 });
146146
147147 test( 'mw.loader', function() {
148 - expect(1);
 148+ expect(2);
149149
 150+ var isAwesomeDone;
 151+
150152 // Asynchronous ahead
151153 stop();
152154
153 - mw.loader.implement( 'is.awesome', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/defineTestCallback.js' )], {}, {} );
 155+ mw.loader.testCallback = function () {
 156+ start();
 157+ strictEqual( isAwesomeDone, undefined, 'Implementing module is.awesome: isAwesomeDone should still be undefined');
 158+ isAwesomeDone = true;
 159+ };
154160
155 - mw.loader.using( 'is.awesome', function() {
 161+ mw.loader.implement( 'is.awesome', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
156162
 163+ mw.loader.using( 'is.awesome', function () {
 164+
157165 // /sample/awesome.js declares the "mw.loader.testCallback" function
158166 // which contains a call to start() and ok()
159 - mw.loader.testCallback();
160 - mw.loader.testCallback = undefined;
 167+ strictEqual(isAwesomeDone, true, "is.awesome module should've caused isAwesomeDone to be true")
 168+ delete mw.loader.testCallback;
161169
162 - }, function() {
 170+ }, function () {
163171 start();
164 - ok( false, 'Error callback fired while implementing "is.awesome" module' );
 172+ ok( false, 'Error callback fired while loader.using "is.awesome" module' );
165173 });
166174
167175 });

Follow-up revisions

RevisionCommit summaryAuthorDate
r112281[JSTesting] mock/restore mw.messages as well, like mw.configkrinkle01:00, 24 February 2012

Status & tagging log