mediawiki.jqueryMsg: Fix regression and add tests.
authorTimo Tijhof <ttijhof@wikimedia.org>
Sun, 20 Jan 2013 01:57:21 +0000 (02:57 +0100)
committerTimo Tijhof <ttijhof@wikimedia.org>
Sun, 20 Jan 2013 01:58:36 +0000 (02:58 +0100)
commit5faaa93a4a916e00fdf7113aea4f970d7dc541fe
tree2b94da4206c123b9274afd4b315f0214476d2192
parentb348efa625f38c3bcd9c1bc6400c38ed6ea7d38f
mediawiki.jqueryMsg: Fix regression and add tests.

From If060b75f.

Thanks to jshint and us using Checkstyle reports in Jenkins
(instead of a boolean good/bad). We also see warnings that are
excluded from the regular count (but can still be useful).

https://integration.mediawiki.org/ci/job/mediawiki-core-lint/4617/checkstyleResult/NORMAL/
> Implied global 'arg'

The html escaping didn't do anything because the condition was
always false (there is no variable there by name of 'arg').

It didn't fail the tests because If060b75f didn't add any tests.

I added proper tests now for "foo [$1 bar]" where $1 is a url
containing characters ("&" specifically) that must not be double
escaped.

The test immediately failed. Addressed the bug in concat instead
of replace. append() is a very powerful jQuery method. It can
append:
* HTMLElement objects
* node lists
* jQuery objects
* Arrays with any of the above
* text strings
* html strings

"html strings" is likely decided by some kind of regex looking
for html-ish characters. Which is exactly what we don't want, we
want it to consider strings always as text, so we make a text
node instead.

And removed the useless if/else block in replace() as it was
always going for the else condition (and should). Effectively
undoing the fix from If060b75f that was supposedly fixing this
bug but didn't.

Change-Id: Ifbeae7e9bd003a33f353d42caffc3ae978c3dc56
resources/mediawiki/mediawiki.jqueryMsg.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js