4 <title>LocalStrings Tests
</title>
9 function testGetString() {
10 var localStrings
= new LocalStrings
;
11 localStrings
.templateData
= {
15 assertEquals(localStrings
.getString('a'), 'apple');
16 assertEquals(localStrings
.getString('b'), 'banana');
19 var consoleWarn
= console
.warn
;
20 console
.warn = function(n
) {
24 assertEquals(localStrings
.getString('blah'), undefined);
26 console
.warn
= consoleWarn
;
28 assertEquals(1, warnings
.length
);
29 assertTrue(warnings
[0].indexOf('blah') > 0);
32 function testGetStringF() {
33 var localStrings
= new LocalStrings
;
34 localStrings
.templateData
= {
38 'd': '$1$2$3$4$5$6$7$8$9'
40 assertEquals(localStrings
.getStringF('a', 'A'), 'A');
41 assertEquals(localStrings
.getStringF('b', 'A', 'B'), 'AB');
42 assertEquals(localStrings
.getStringF('b', 'A'),
44 assertEquals(localStrings
.getStringF('c', 'A', 'B', 'C'),
46 assertEquals(localStrings
.getStringF('c', 'A'),
47 'Aundefinedundefined');
48 assertEquals(localStrings
.getStringF('d', 'A', 'B', 'C',
49 'D', 'E', 'F', 'G', 'H', 'I'), 'ABCDEFGHI');
50 assertThrows(function() {
51 localStrings
.getStringF('e', 'A');