( function ( $, mw ) {
QUnit.module( 'jquery.localize', QUnit.newMwEnvironment() );
- QUnit.test( 'Handle basic replacements', 4, function ( assert ) {
+ QUnit.test( 'Handle basic replacements', function ( assert ) {
var html, $lc;
mw.messages.set( 'basic', 'Basic stuff' );
assert.strictEqual( $lc.attr( 'placeholder' ), 'Basic stuff', 'Attribute: placeholder-msg' );
} );
- QUnit.test( 'Proper escaping', 2, function ( assert ) {
+ QUnit.test( 'Proper escaping', function ( assert ) {
var html, $lc;
mw.messages.set( 'properfoo', '<proper esc="test">' );
assert.strictEqual( $lc.attr( 'title' ), mw.msg( 'properfoo' ), 'Attributes are not inserted raw.' );
} );
- QUnit.test( 'Options', 7, function ( assert ) {
+ QUnit.test( 'Options', function ( assert ) {
+ var html, $lc, x, sitename = 'Wikipedia';
mw.messages.set( {
'foo-lorem': 'Lorem',
'foo-ipsum': 'Ipsum',
'foo-bazz-label': 'The Bazz ($1)',
'foo-welcome': 'Welcome to $1! (last visit: $2)'
} );
- var html, $lc, x, sitename = 'Wikipedia';
// Message key prefix
html = '<div><span title-msg="lorem"><html:msg key="ipsum" /></span></div>';
html = '<div><span title-msg="title"><html:msg key="label" /></span></div>';
$lc = $( html ).localize( {
keys: {
- 'title': 'foo-' + x + '-title',
- 'label': 'foo-' + x + '-label'
+ title: 'foo-' + x + '-title',
+ label: 'foo-' + x + '-label'
}
} ).find( 'span' );
html = '<div><span><html:msg key="foo-welcome" /></span></div>';
$lc = $( html ).localize( {
params: {
- 'foo-welcome': [sitename, 'yesterday']
+ 'foo-welcome': [ sitename, 'yesterday' ]
}
} ).find( 'span' );
$lc = $( html ).localize( {
prefix: 'foo-',
keys: {
- 'title': x + '-title',
- 'label': x + '-label'
+ title: x + '-title',
+ label: x + '-label'
},
params: {
- 'title': [sitename, '3 minutes ago'],
- 'label': [sitename, '3 minutes ago']
+ title: [ sitename, '3 minutes ago' ],
+ label: [ sitename, '3 minutes ago' ]
}
} ).find( 'span' );
assert.strictEqual( $lc.attr( 'title' ), 'Read more about bazz at Wikipedia (last modified: 3 minutes ago)', 'Combination of options prefix, params and keys - attr' );
} );
- QUnit.test( 'Handle data text', 2, function ( assert ) {
+ QUnit.test( 'Handle data text', function ( assert ) {
var html, $lc;
mw.messages.set( 'option-one', 'Item 1' );
mw.messages.set( 'option-two', 'Item 2' );
assert.strictEqual( $lc.eq( 1 ).text(), mw.msg( 'option-two' ), 'data-msg-text becomes text of options' );
} );
- QUnit.test( 'Handle data html', 2, function ( assert ) {
+ QUnit.test( 'Handle data html', function ( assert ) {
var html, $lc;
mw.messages.set( 'html', 'behold... there is a <a>link</a> here!!' );
html = '<div><div data-msg-html="html"></div></div>';