X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fqunit%2Fsuites%2Fresources%2Fmediawiki%2Fmediawiki.jqueryMsg.test.js;h=7701170b9626482b6b3a8d1ef124b3596272a210;hb=138298b397b308ad6e4bfc7088884d90e8ac1e37;hp=71362fd0d1498fed24505cc240b89373ff0c5fd6;hpb=0eb1619898438735b04293b5aef9a36650258741;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js index 71362fd0d1..7701170b96 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js @@ -7,8 +7,8 @@ // When the expected result is the same in both modes function assertBothModes( assert, parserArguments, expectedResult, assertMessage ) { - assert.equal( formatText.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'text\'' ); - assert.equal( formatParse.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'parse\'' ); + assert.strictEqual( formatText.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'text\'' ); + assert.strictEqual( formatParse.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'parse\'' ); } QUnit.module( 'mediawiki.jqueryMsg', QUnit.newMwEnvironment( { @@ -152,13 +152,13 @@ QUnit.test( 'Replace', function ( assert ) { mw.messages.set( 'simple', 'Foo $1 baz $2' ); - assert.equal( formatParse( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' ); - assert.equal( formatParse( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' ); - assert.equal( formatParse( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' ); + assert.strictEqual( formatParse( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' ); + assert.strictEqual( formatParse( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' ); + assert.strictEqual( formatParse( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' ); mw.messages.set( 'plain-input', 'x$1y<z' ); - assert.equal( + assert.strictEqual( formatParse( 'plain-input', 'bar' ), '<foo foo="foo">xbary&lt;</foo>z', 'Input is not considered html' @@ -166,7 +166,7 @@ mw.messages.set( 'plain-replace', 'Foo $1' ); - assert.equal( + assert.strictEqual( formatParse( 'plain-replace', '>' ), 'Foo <bar bar="bar">&gt;</bar>', 'Replacement is not considered html' @@ -174,55 +174,55 @@ mw.messages.set( 'object-replace', 'Foo $1' ); - assert.equal( + assert.strictEqual( formatParse( 'object-replace', $( '
>
' ) ), 'Foo
>
', 'jQuery objects are preserved as raw html' ); - assert.equal( + assert.strictEqual( formatParse( 'object-replace', $( '
>
' ).get( 0 ) ), 'Foo
>
', 'HTMLElement objects are preserved as raw html' ); - assert.equal( + assert.strictEqual( formatParse( 'object-replace', $( '
>
' ).toArray() ), 'Foo
>
', 'HTMLElement[] arrays are preserved as raw html' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-replace', 'http://example.org/?x=y&z' ), 'Foo bar', 'Href is not double-escaped in wikilink function' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-plural', 1, 'http://example.org' ), 'Foo is one things.', 'Link is expanded inside plural and is not escaped html' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-plural', 2, 'http://example.org' ), 'Foo two things.', 'Link is expanded inside an explicit plural form and is not escaped html' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-plural', 3 ), 'Foo three things.', 'A simple explicit plural form co-existing with complex explicit plural forms' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-plural', 4, 'http://example.org' ), 'Foo a=b things.', 'Only first equal sign is used as delimiter for explicit plural form. Repeated equal signs does not create issue' ); - assert.equal( + assert.strictEqual( formatParse( 'external-link-plural', 6, 'http://example.org' ), 'Foo are some things.', 'Plural fallback to the "other" plural form' ); - assert.equal( + assert.strictEqual( formatParse( 'plural-only-explicit-forms', 2 ), 'It is a double room.', 'Plural with explicit forms alone.' @@ -230,15 +230,15 @@ } ); QUnit.test( 'Plural', function ( assert ) { - assert.equal( formatParse( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' ); - assert.equal( formatParse( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' ); - assert.equal( formatParse( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' ); - assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 6 ), 'Found 6 results', 'Plural message with explicit plural forms' ); - assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 0 ), 'Found no results in Wiki', 'Plural message with explicit plural forms, with nested {{SITENAME}}' ); - assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 1 ), 'Found 1 result', 'Plural message with explicit plural forms with placeholder nested' ); - assert.equal( formatParse( 'plural-empty-explicit-form', 0 ), 'There is me.' ); - assert.equal( formatParse( 'plural-empty-explicit-form', 1 ), 'There is me and other people.' ); - assert.equal( formatParse( 'plural-empty-explicit-form', 2 ), 'There is me and other people.' ); + assert.strictEqual( formatParse( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' ); + assert.strictEqual( formatParse( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' ); + assert.strictEqual( formatParse( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' ); + assert.strictEqual( formatParse( 'plural-msg-explicit-forms-nested', 6 ), 'Found 6 results', 'Plural message with explicit plural forms' ); + assert.strictEqual( formatParse( 'plural-msg-explicit-forms-nested', 0 ), 'Found no results in Wiki', 'Plural message with explicit plural forms, with nested {{SITENAME}}' ); + assert.strictEqual( formatParse( 'plural-msg-explicit-forms-nested', 1 ), 'Found 1 result', 'Plural message with explicit plural forms with placeholder nested' ); + assert.strictEqual( formatParse( 'plural-empty-explicit-form', 0 ), 'There is me.' ); + assert.strictEqual( formatParse( 'plural-empty-explicit-form', 1 ), 'There is me and other people.' ); + assert.strictEqual( formatParse( 'plural-empty-explicit-form', 2 ), 'There is me and other people.' ); } ); QUnit.test( 'Gender', function ( assert ) { @@ -247,53 +247,53 @@ // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian mw.user.options.set( 'gender', 'male' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'Bob', 'male' ), 'Bob: blue', 'Masculine from string "male"' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'Bob', mw.user ), 'Bob: blue', 'Masculine from mw.user object' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-currentuser' ), 'blue', 'Masculine for current user' ); mw.user.options.set( 'gender', 'female' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'Alice', 'female' ), 'Alice: pink', 'Feminine from string "female"' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'Alice', mw.user ), 'Alice: pink', 'Feminine from mw.user object' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-currentuser' ), 'pink', 'Feminine for current user' ); mw.user.options.set( 'gender', 'unknown' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'Foo', mw.user ), 'Foo: green', 'Neutral from mw.user object' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'User' ), 'User: green', 'Neutral when no parameter given' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg', 'User', 'unknown' ), 'User: green', 'Neutral from string "unknown"' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-currentuser' ), 'green', 'Neutral for current user' @@ -301,31 +301,31 @@ mw.messages.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-one-form', 'male', 10 ), 'User: 10 edits', 'Gender neutral and plural form' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-one-form', 'female', 1 ), 'User: 1 edit', 'Gender neutral and singular form' ); mw.messages.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-lowercase', 'male' ), 'he is awesome', 'Gender masculine' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-lowercase', 'female' ), 'she is awesome', 'Gender feminine' ); mw.messages.set( 'gender-msg-wrong', '{{gender}} test' ); - assert.equal( + assert.strictEqual( formatParse( 'gender-msg-wrong', 'female' ), ' test', 'Invalid syntax should result in {{gender}} simply being stripped away' @@ -336,32 +336,32 @@ QUnit.test( 'Case changing', function ( assert ) { mw.messages.set( 'to-lowercase', '{{lc:thIS hAS MEsSed uP CapItaliZatiON}}' ); - assert.equal( formatParse( 'to-lowercase' ), 'this has messed up capitalization', 'To lowercase' ); + assert.strictEqual( formatParse( 'to-lowercase' ), 'this has messed up capitalization', 'To lowercase' ); mw.messages.set( 'to-caps', '{{uc:thIS hAS MEsSed uP CapItaliZatiON}}' ); - assert.equal( formatParse( 'to-caps' ), 'THIS HAS MESSED UP CAPITALIZATION', 'To caps' ); + assert.strictEqual( formatParse( 'to-caps' ), 'THIS HAS MESSED UP CAPITALIZATION', 'To caps' ); mw.messages.set( 'uc-to-lcfirst', '{{lcfirst:THis hAS MEsSed uP CapItaliZatiON}}' ); mw.messages.set( 'lc-to-lcfirst', '{{lcfirst:thIS hAS MEsSed uP CapItaliZatiON}}' ); - assert.equal( formatParse( 'uc-to-lcfirst' ), 'tHis hAS MEsSed uP CapItaliZatiON', 'Lcfirst caps' ); - assert.equal( formatParse( 'lc-to-lcfirst' ), 'thIS hAS MEsSed uP CapItaliZatiON', 'Lcfirst lowercase' ); + assert.strictEqual( formatParse( 'uc-to-lcfirst' ), 'tHis hAS MEsSed uP CapItaliZatiON', 'Lcfirst caps' ); + assert.strictEqual( formatParse( 'lc-to-lcfirst' ), 'thIS hAS MEsSed uP CapItaliZatiON', 'Lcfirst lowercase' ); mw.messages.set( 'uc-to-ucfirst', '{{ucfirst:THis hAS MEsSed uP CapItaliZatiON}}' ); mw.messages.set( 'lc-to-ucfirst', '{{ucfirst:thIS hAS MEsSed uP CapItaliZatiON}}' ); - assert.equal( formatParse( 'uc-to-ucfirst' ), 'THis hAS MEsSed uP CapItaliZatiON', 'Ucfirst caps' ); - assert.equal( formatParse( 'lc-to-ucfirst' ), 'ThIS hAS MEsSed uP CapItaliZatiON', 'Ucfirst lowercase' ); + assert.strictEqual( formatParse( 'uc-to-ucfirst' ), 'THis hAS MEsSed uP CapItaliZatiON', 'Ucfirst caps' ); + assert.strictEqual( formatParse( 'lc-to-ucfirst' ), 'ThIS hAS MEsSed uP CapItaliZatiON', 'Ucfirst lowercase' ); mw.messages.set( 'mixed-to-sentence', '{{ucfirst:{{lc:thIS hAS MEsSed uP CapItaliZatiON}}}}' ); - assert.equal( formatParse( 'mixed-to-sentence' ), 'This has messed up capitalization', 'To sentence case' ); + assert.strictEqual( formatParse( 'mixed-to-sentence' ), 'This has messed up capitalization', 'To sentence case' ); mw.messages.set( 'all-caps-except-first', '{{lcfirst:{{uc:thIS hAS MEsSed uP CapItaliZatiON}}}}' ); - assert.equal( formatParse( 'all-caps-except-first' ), 'tHIS HAS MESSED UP CAPITALIZATION', 'To opposite sentence case' ); + assert.strictEqual( formatParse( 'all-caps-except-first' ), 'tHIS HAS MESSED UP CAPITALIZATION', 'To opposite sentence case' ); } ); QUnit.test( 'Grammar', function ( assert ) { - assert.equal( formatParse( 'grammar-msg' ), 'Przeszukaj Wiki', 'Grammar Test with sitename' ); + assert.strictEqual( formatParse( 'grammar-msg' ), 'Przeszukaj Wiki', 'Grammar Test with sitename' ); mw.messages.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' ); - assert.equal( formatParse( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ', 'Grammar Test with wrong grammar template syntax' ); + assert.strictEqual( formatParse( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ', 'Grammar Test with wrong grammar template syntax' ); } ); QUnit.test( 'Match PHP parser', function ( assert ) { @@ -375,7 +375,7 @@ var parser; mw.config.set( 'wgUserLanguage', test.lang ); parser = new mw.jqueryMsg.Parser( { language: langClass } ); - assert.equal( + assert.strictEqual( parser.parse( test.key, test.args ).html(), test.result, test.name @@ -427,17 +427,17 @@ mw.messages.set( 'reverse-pipe-trick', '[[|Tampa, Florida]]' ); mw.messages.set( 'empty-link', '[[]]' ); this.suppressWarnings(); - assert.equal( + assert.strictEqual( formatParse( 'pipe-trick' ), '[[Tampa, Florida|]]', 'Pipe trick should not be parsed.' ); - assert.equal( + assert.strictEqual( formatParse( 'reverse-pipe-trick' ), '[[|Tampa, Florida]]', 'Reverse pipe trick should not be parsed.' ); - assert.equal( + assert.strictEqual( formatParse( 'empty-link' ), '[[]]', 'Empty link should not be parsed.' @@ -623,7 +623,7 @@ // Test non-{{ wikitext, where behavior differs // Wikilink - assert.equal( + assert.strictEqual( formatText( 'jquerymsg-test-statistics-users' ), mw.messages.get( 'jquerymsg-test-statistics-users' ), 'Internal link message unchanged when format is \'text\'' @@ -635,7 +635,7 @@ ); // External link - assert.equal( + assert.strictEqual( formatText( 'jquerymsg-test-version-entrypoints-index-php' ), mw.messages.get( 'jquerymsg-test-version-entrypoints-index-php' ), 'External link message unchanged when format is \'text\'' @@ -647,7 +647,7 @@ ); // External link with parameter - assert.equal( + assert.strictEqual( formatText( 'external-link-replace', 'http://example.com' ), 'Foo [http://example.com bar]', 'External link message only substitutes parameter when format is \'text\'' @@ -689,7 +689,7 @@ 'Link with nested message' ); - assert.equal( + assert.strictEqual( formatParse( 'see-portal-url' ), 'Project:Community portal is an important community page.', 'Nested message' @@ -706,7 +706,7 @@ mw.messages.set( 'uses-missing-int', '{{int:doesnt-exist}}' ); - assert.equal( + assert.strictEqual( formatParse( 'uses-missing-int' ), '⧼doesnt-exist⧽', 'int: where nested message does not exist' @@ -715,28 +715,28 @@ QUnit.test( 'Ns', function ( assert ) { mw.messages.set( 'ns-template-talk', '{{ns:Template talk}}' ); - assert.equal( + assert.strictEqual( formatParse( 'ns-template-talk' ), 'Dyskusja szablonu', 'ns: returns localised namespace when used with a canonical namespace name' ); mw.messages.set( 'ns-10', '{{ns:10}}' ); - assert.equal( + assert.strictEqual( formatParse( 'ns-10' ), 'Szablon', 'ns: returns localised namespace when used with a namespace number' ); mw.messages.set( 'ns-unknown', '{{ns:doesnt-exist}}' ); - assert.equal( + assert.strictEqual( formatParse( 'ns-unknown' ), '', 'ns: returns empty string for unknown namespace name' ); mw.messages.set( 'ns-in-a-link', '[[{{ns:template}}:Foo]]' ); - assert.equal( + assert.strictEqual( formatParse( 'ns-in-a-link' ), 'Szablon:Foo', 'ns: works when used inside a wikilink' @@ -810,7 +810,7 @@ { lang: 'ar', number: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١', - result: 987654321, + result: '987654321', integer: true, description: 'formatnum test for Arabic, with decimal separator, reverse' }, @@ -823,7 +823,7 @@ { lang: 'ar', number: '-١٢٫٨٩', - result: -12, + result: '-12', integer: true, description: 'formatnum test for Arabic, negative number, reverse' }, @@ -905,7 +905,7 @@ var parser; mw.config.set( 'wgUserLanguage', test.lang ); parser = new mw.jqueryMsg.Parser( { language: langClass } ); - assert.equal( + assert.strictEqual( parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg', [ test.number ] ).html(), test.result, @@ -944,7 +944,7 @@ 'Italics with link inside in parse mode' ); - assert.equal( + assert.strictEqual( formatText( 'jquerymsg-italics-with-link' ), mw.messages.get( 'jquerymsg-italics-with-link' ), 'Italics with link unchanged in text mode' @@ -971,7 +971,7 @@ 'Tag outside whitelist escaped in parse mode' ); - assert.equal( + assert.strictEqual( formatText( 'jquerymsg-script-msg' ), mw.messages.get( 'jquerymsg-script-msg' ), 'Tag outside whitelist unchanged in text mode' @@ -1007,14 +1007,14 @@ // Intentionally not using htmlEqual for the quote tests mw.messages.set( 'jquerymsg-double-quotes-preserved', 'Double' ); - assert.equal( + assert.strictEqual( formatParse( 'jquerymsg-double-quotes-preserved' ), mw.messages.get( 'jquerymsg-double-quotes-preserved' ), 'Attributes with double quotes are preserved as such' ); mw.messages.set( 'jquerymsg-single-quotes-normalized-to-double', 'Single' ); - assert.equal( + assert.strictEqual( formatParse( 'jquerymsg-single-quotes-normalized-to-double' ), 'Single', 'Attributes with single quotes are normalized to double' @@ -1110,21 +1110,21 @@ QUnit.test( 'Nowiki', function ( assert ) { mw.messages.set( 'jquerymsg-nowiki-link', 'Foo [[bar]] baz.' ); - assert.equal( + assert.strictEqual( formatParse( 'jquerymsg-nowiki-link' ), 'Foo [[bar]] baz.', 'Link inside nowiki is not parsed' ); mw.messages.set( 'jquerymsg-nowiki-htmltag', 'Foo bar baz.' ); - assert.equal( + assert.strictEqual( formatParse( 'jquerymsg-nowiki-htmltag' ), 'Foo <b>bar</b> baz.', 'HTML inside nowiki is not parsed and escaped' ); mw.messages.set( 'jquerymsg-nowiki-template', 'Foo {{bar}} baz.' ); - assert.equal( + assert.strictEqual( formatParse( 'jquerymsg-nowiki-template' ), 'Foo {{bar}} baz.', 'Template inside nowiki is not parsed and does not cause a parse error' @@ -1138,19 +1138,19 @@ this.suppressWarnings(); logSpy = this.sandbox.spy( mw.log, 'warn' ); - assert.equal( + assert.strictEqual( formatParse( 'invalid-wikitext' ), '<b>{{FAIL}}</b>', 'Invalid wikitext: \'parse\' format' ); - assert.equal( + assert.strictEqual( formatText( 'invalid-wikitext' ), '{{FAIL}}', 'Invalid wikitext: \'text\' format' ); - assert.equal( logSpy.callCount, 2, 'mw.log.warn calls' ); + assert.strictEqual( logSpy.callCount, 2, 'mw.log.warn calls' ); } ); QUnit.test( 'Integration', function ( assert ) { @@ -1159,13 +1159,13 @@ expected = 'Bold!'; mw.messages.set( 'integration-test', '[[Bold]]!' ); - assert.equal( + assert.strictEqual( mw.message( 'integration-test' ).parse(), expected, 'mw.message().parse() works correctly' ); - assert.equal( + assert.strictEqual( $( '' ).msg( 'integration-test' ).html(), expected, 'jQuery plugin $.fn.msg() works correctly' @@ -1177,7 +1177,7 @@ $( '' ).attr( 'href', 'http://example.com/' ) ); msg.parse(); // Not a no-op - assert.equal( + assert.strictEqual( msg.parse(), 'Link', 'Calling .parse() multiple times does not duplicate link contents'