var expect = require('chai').expect;
var storage = require('../storage');
var utility = require('../utility');

describe('text.localize', function() {
    var text = new storage.Localizable({
        key1: 'value',
        key2: 'value [_1]',
    });
    it('should try to return a string from the localised texts', function() {
        expect(text.localize('key')).to.equal('key');
        expect(text.localize('key1')).to.equal('value');
    });

    it('should only template when required', function() {
        expect(text.localize('key2')).to.equal('value [_1]');
        // inject global template function
        global.template = utility.template;
        expect(text.localize('key2', [1])).to.equal('value 1');
        delete global.template;
    });
});

@@ -236,24 +236,128 @@
  %5B_1%5D',%0A
+        'You_can_view_your_%5B_1%5Dtrading_limits_here_': 'Ihre %5B_1%5D Handelslimits sind hier ersichtlich.',%0A
     %7D);%0A
     it('
@@ -348,16 +348,16 @@
     %7D);%0A
-
     it('
@@ -533,24 +533,173 @@
 l('value');%0A
+        expect(text.localize('You can view your %5B_1%5Dtrading limits here.'))%0A            .to.equal('Ihre %5B_1%5D Handelslimits sind hier ersichtlich.');%0A
     %7D);%0A%0A   
@@ -898,24 +898,24 @@
 y.template;%0A
-
         expe
@@ -962,24 +962,193 @@
 'value 1');%0A
+        expect(text.localize('You can view your %5B_1%5Dtrading limits here.', %5B'something'%5D))%0A            .to.equal('Ihre something Handelslimits sind hier ersichtlich.');%0A
         dele

Test with data from real localisation