summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/qunit/ext.translate.parsers.test.js
blob: 4c1231ade971d485474db167ab2220c4ebf531ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*!
 * Tests for ext.translate.parsers.js.
 *
 * @license GPL-2.0+
 */

( function ( $, mw ) {
	'use strict';

	QUnit.module( 'ext.translate.parsers', QUnit.newMwEnvironment() );

	QUnit.test( '-- External links', 3, function ( assert ) {
		mw.config.set( 'wgArticlePath', '/wiki/$1' );

		assert.strictEqual(
			'This page is [in English]',
			mw.translate.formatMessageGently( 'This page is [in English]' ),
			'Brackets without protocol doesn\'t make a link'
		);

		assert.strictEqual(
			'This page has <a href="https://www.mediawiki.org">a link</a>',
			mw.translate.formatMessageGently( 'This page has [https://www.mediawiki.org a link]' ),
			'Brackets with https:// protocol creates a link'
		);

		assert.strictEqual(
			'No kun <a href="/wiki/m:MassMessage">m:MassMessage</a> ja plum <a href="/wiki/m:">Meta-Wiki</a>.',
			mw.translate.formatMessageGently( 'No kun [[m:MassMessage]] ja plum [[m:|Meta-Wiki]].' ),
			'Link parsing is non-greedy'
		);
	} );
}( jQuery, mediaWiki ) );