-
Notifications
You must be signed in to change notification settings - Fork 29
/
testI18N.js
63 lines (46 loc) · 1.58 KB
/
testI18N.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Copyright (c) 2014-2015 F-Secure
See LICENSE for details
*/
'use strict';
var I18N = require('../lib/i18n');
var i18n = new I18N();
module.exports = {
setUp: function(callback) {
i18n._addString('en-US', 'test.withParams', '%test1% is %test2%');
i18n._addString('en-US', 'test.DoNotTranslate2', 'test2');
callback();
},
testDefaultLanguage: function(test) {
test.equal(i18n.getDefaultLanguage(), 'en-US');
test.done();
},
testExistingId: function(test) {
test.equal(i18n.getLocalizedString('en-US', 'test.DoNotTranslate'), 'test');
test.done();
},
testLocalizedId: function(test) {
test.equal(i18n.getLocalizedString('ru-RU', 'test.DoNotTranslate'), 'тест');
test.done();
},
testLocalizedIdWithParams: function(test) {
test.equal(i18n.getLocalizedString('ru-RU', 'test.withParams', 'test1', 'Oleg', 'test2', 'good'), 'Oleg is good');
test.done();
},
testMissingLocalizedIdShouldFallbackToEnglish: function(test) {
test.equal(i18n.getLocalizedString('ru-RU', 'test.DoNotTranslate2'), 'test2');
test.done();
},
testWrongId: function(test) {
test.equal(i18n.getLocalizedString('en-US', 'somewrongid'), '');
test.done();
},
testShortIdEn: function(test) {
test.equal(i18n.getLocalizedString('en', 'test.DoNotTranslate'), 'test');
test.done();
},
testShortIdFi: function(test) {
test.equal(i18n.getLocalizedString('fi', 'test.DoNotTranslate'), 'testi');
test.done();
}
};