Add tests for translator static methods

v1.18.x
Peter Jaszkowiak 8 years ago
parent 375af7ad53
commit a81aad61ab

@ -395,11 +395,13 @@
/**
* Construct a translator pattern
* @param {string} name - Translation name
* @param {...string} arg - Optional argument for the pattern
*/
Translator.compile = function compile() {
var args = Array.prototype.slice.call(arguments, 0);
var args = Array.prototype.slice.call(arguments, 0);
return '[[' + args.join(', ') + ']]';
return '[[' + args.join(', ') + ']]';
};
return Translator;

@ -223,4 +223,33 @@ describe('Translator static methods', function () {
done();
});
});
describe('.escape', function () {
it('should escape translation patterns within text', function (done) {
assert.strictEqual(
Translator.escape('some nice text [[global:home]] here'),
'some nice text \\[\\[global:home\\]\\] here'
);
done();
});
});
describe('.unescape', function () {
it('should unescape escaped translation patterns within text', function (done) {
assert.strictEqual(
Translator.unescape('some nice text \\[\\[global:home\\]\\] here'),
'some nice text [[global:home]] here'
);
done();
});
});
describe('.compile', function () {
it('should create a translator pattern from a key and list of arguments', function (done) {
assert.strictEqual(
Translator.compile('amazing:cool', 'awesome', 'great'),
'[[amazing:cool, awesome, great]]'
);
done();
});
});
});

Loading…
Cancel
Save