Permalink
Browse files

write a failing test for issue #2011

  • Loading branch information...
1 parent 12cd056 commit c23cfe5f9cf18f6aea1e4f7977b7b200b0d4df59 @lloyd lloyd committed Jul 13, 2012
Showing with 20 additions and 2 deletions.
  1. +3 −0 lib/static/views.js
  2. +1 −0 resources/views/i18n_fallback_test.ejs
  3. +12 −2 tests/i18n-tests.js
  4. +4 −0 tests/i18n_test_files/bg/messages.json
View
@@ -202,6 +202,9 @@ exports.setup = function(app) {
app.get('/i18n_test', function(req, res) {
renderCachableView(req, res, 'i18n_test.ejs', { layout: false, title: 'l10n testing title' });
});
+ app.get('/i18n_fallback_test', function(req, res) {
+ renderCachableView(req, res, 'i18n_fallback_test.ejs', { layout: false, title: 'l10n testing title' });
+ });
} else {
// this is stage or production, explicitly disable all resources under /test
app.get(/^\/test/, function(req, res) {
@@ -0,0 +1 @@
+<%- gettext("This is not translated") %>
View
@@ -111,13 +111,14 @@ process.env['SUPPORTED_LANGUAGES'] = 'en,bg,it-CH';
// now let's start up our servers
start_stop.addStartupBatches(suite);
-function getTestTemplate(langs) {
+function getTestTemplate(langs, tp) {
+ tp = tp || '/i18n_test';
return function() {
var self = this;
var req = http.request({
host: '127.0.0.1',
port: 10002,
- path: '/i18n_test',
+ path: tp,
method: "GET",
headers: { 'Accept-Language': langs }
}, function (res) {
@@ -171,7 +172,16 @@ suite.addBatch({
assert.strictEqual(200, r.code);
assert.strictEqual(r.body.trim(), "Прова? Прова? Четери, пет, шещ?");
}
+ },
+ // test .json extraction fallback when translation is the empty string
+ "bulgarian accept headers without a translation": {
+ topic: getTestTemplate('bg', '/i18n_fallback_test'),
+ "return a non-translated string" : function(err, r) {
+ assert.strictEqual(200, r.code);
+ assert.strictEqual(r.body.trim(), "This is not translated");
+ }
}
+
});
// and let's stop them servers
@@ -3,6 +3,10 @@ var json_locale_data = {
"This is a translation <strong>test</strong> string.": [
null,
"Прова? Прова? Четери, пет, шещ?"
+ ],
+ "This is not translated": [
+ null,
+ ""
]
}
};

0 comments on commit c23cfe5

Please sign in to comment.