r112368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112367‎ | r112368 | r112369 >
Date:23:13, 24 February 2012
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
[JSTesting] Add more mw.loader tests
* Follows-up r12279, r112281
* Follows-up r110988: Adds test for @import (currently failing: bug 34669)
* Adding StyleTest.css.php for making this easier and re-usable
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
@@ -148,7 +148,7 @@
149149
150150 var isAwesomeDone;
151151
152 - // Asynchronous ahead
 152+ // Async ahead
153153 stop();
154154
155155 mw.loader.testCallback = function () {
@@ -157,23 +157,74 @@
158158 isAwesomeDone = true;
159159 };
160160
161 - mw.loader.implement( 'is.awesome', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
 161+ mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
162162
163 - mw.loader.using( 'is.awesome', function () {
 163+ mw.loader.using( 'test.callback', function () {
164164
165165 // /sample/awesome.js declares the "mw.loader.testCallback" function
166166 // which contains a call to start() and ok()
167 - strictEqual(isAwesomeDone, true, "is.awesome module should've caused isAwesomeDone to be true")
 167+ strictEqual( isAwesomeDone, true, "test.callback module should've caused isAwesomeDone to be true" );
168168 delete mw.loader.testCallback;
169169
170170 }, function () {
171171 start();
172 - ok( false, 'Error callback fired while loader.using "is.awesome" module' );
 172+ ok( false, 'Error callback fired while loader.using "test.callback" module' );
173173 });
 174+});
174175
 176+test( 'mw.loader.implement', function () {
 177+ expect(5 - 2);
 178+
 179+ var isJsExecuted, $element;
 180+
 181+ // Async ahead
 182+ stop();
 183+
 184+ mw.loader.implement(
 185+ 'test.implement',
 186+ function () {
 187+ start();
 188+
 189+ strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
 190+ isJsExecuted = true;
 191+
 192+ equal( mw.loader.getState( 'test.implement' ), 'loaded', 'module state is "loaded" while implement() is executing javascript' );
 193+
 194+ $element = $( '<div class="mw-test-loaderimplement">Foo bar</div>' );
 195+ $element.appendTo( 'body' );
 196+
 197+ // @broken: equal( $element.css( 'text-align' ),'center', 'CSS stylesheet was applied in time. ("text-align: center")' );
 198+
 199+ // Marked broken due to a bug in qunit/index.html, via Special:JavaScriptTest/qunit it works fine
 200+
 201+ // CSS @import is easily broken when concatenating stylesheets (bug 34669)
 202+ // @broken: equal( $element.css( 'float' ), 'right', 'CSS stylesheet was applied in time via @import (bug 34669). ("float: right")' );
 203+
 204+ equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded in time' );
 205+
 206+ },
 207+ {
 208+ "all": "@import url('"
 209+ + QUnit.fixurl( mw.config.get( 'wgScriptPath' )
 210+ + '/tests/qunit/data/styleTest.css.php?'
 211+ + $.param({
 212+ selector: '.mw-test-loaderimplement',
 213+ prop: 'float',
 214+ val: 'right'
 215+ }) )
 216+ + "');\n"
 217+ + '.mw-test-loaderimplement { text-align: center; }'
 218+ },
 219+ {
 220+ "test-foobar": "Hello Foobar, $1!"
 221+ }
 222+ );
 223+
 224+ mw.loader.load( 'test.implement' );
 225+
175226 });
176227
177 -test( 'mw.loader.bug29107' , function() {
 228+test( 'mw.loader bug29107' , function () {
178229 expect(2);
179230
180231 // Message doesn't exist already

Follow-up revisions

RevisionCommit summaryAuthorDate
r112369[JSTesting] actually commit the file (follows-up r112368)krinkle23:14, 24 February 2012
r112996[mediawiki.test] follow-up r112368: Append to fixture instead of body. Otherw...krinkle01:47, 5 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r12279* (bug 3794) Include OS / platform info in Special:Versionrobchurch02:49, 29 December 2005
r110988(bug 31676) Group dynamically inserted CSS into a single <style> tag, because...catrope00:10, 9 February 2012
r112281[JSTesting] mock/restore mw.messages as well, like mw.configkrinkle01:00, 24 February 2012

Comments

#Comment by Krinkle (talk | contribs)   23:17, 24 February 2012

The styleTest.css.php file is for basic stylesheet generation to be used in unit tests to check if a file is loaded properly e.g. .php?selector=.mw-test-foobar&prop=margin&val=24px

Status & tagging log