+/*jshint -W024 */
( function ( mw, $ ) {
var specialCharactersPageName;
QUnit.module( 'mediawiki', QUnit.newMwEnvironment( {
setup: function () {
- // Messages used in multiple tests
- mw.messages.set( {
- 'other-message': 'Other Message',
- 'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of deletion nomination for [[$1]]',
- 'gender-plural-msg': '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome',
- 'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
- 'formatnum-msg': '{{formatnum:$1}}',
- 'int-msg': 'Some {{int:other-message}}',
- 'mediawiki-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
- 'external-link-replace': 'Foo [$1 bar]'
- } );
-
- mw.config.set( {
- wgArticlePath: '/wiki/$1',
-
- // For formatnum tests
- wgUserLanguage: 'en'
- } );
-
specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
+ },
+ config: {
+ wgArticlePath: '/wiki/$1',
+
+ // For formatnum tests
+ wgUserLanguage: 'en'
+ },
+ // Messages used in multiple tests
+ messages: {
+ 'other-message': 'Other Message',
+ 'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of deletion nomination for [[$1]]',
+ 'gender-plural-msg': '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome',
+ 'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
+ 'formatnum-msg': '{{formatnum:$1}}',
+ 'int-msg': 'Some {{int:other-message}}',
+ 'mediawiki-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
+ 'external-link-replace': 'Foo [$1 bar]'
}
} ) );
QUnit.test( 'Initial check', 8, function ( assert ) {
assert.ok( window.jQuery, 'jQuery defined' );
- assert.ok( window.$, '$j defined' );
- assert.ok( window.$j, '$j defined' );
+ assert.ok( window.$, '$ defined' );
assert.strictEqual( window.$, window.jQuery, '$ alias to jQuery' );
+
+ this.suppressWarnings();
+ assert.ok( window.$j, '$j defined' );
assert.strictEqual( window.$j, window.jQuery, '$j alias to jQuery' );
+ this.restoreWarnings();
+ // window.mw and window.mediaWiki are not deprecated, but for some reason
+ // PhantomJS is triggerring the accessors on all mw.* properties in this test,
+ // and with that lots of unrelated deprecation notices.
+ this.suppressWarnings();
assert.ok( window.mediaWiki, 'mediaWiki defined' );
assert.ok( window.mw, 'mw defined' );
assert.strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
+ this.restoreWarnings();
} );
QUnit.test( 'mw.Map', 28, function ( assert ) {
} );
- QUnit.test( 'mw.hook', 10, function ( assert ) {
+ QUnit.test( 'mw.hook', 13, function ( assert ) {
var hook, add, fire, chars, callback;
mw.hook( 'test.hook.unfired' ).add( function () {
} );
mw.hook( 'test.hook.basic' ).fire();
+ mw.hook( 'hasOwnProperty' ).add( function () {
+ assert.ok( true, 'hook with name of predefined method' );
+ } );
+ mw.hook( 'hasOwnProperty' ).fire();
+
mw.hook( 'test.hook.data' ).add( function ( data1, data2 ) {
assert.equal( data1, 'example', 'Fire with data (string param)' );
assert.deepEqual( data2, ['two'], 'Fire with data (array param)' );
} );
mw.hook( 'test.hook.data' ).fire( 'example', ['two'] );
- mw.hook( 'test.hook.chainable' ).add( function () {
- assert.ok( true, 'Chainable' );
- } ).fire();
+ hook = mw.hook( 'test.hook.chainable' );
+ assert.strictEqual( hook.add(), hook, 'hook.add is chainable' );
+ assert.strictEqual( hook.remove(), hook, 'hook.remove is chainable' );
+ assert.strictEqual( hook.fire(), hook, 'hook.fire is chainable' );
hook = mw.hook( 'test.hook.detach' );
add = hook.add;