Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
71
gaia/apps/sharedtest/test/unit/l10n/lib/context/basic_test.js
Executable file
71
gaia/apps/sharedtest/test/unit/l10n/lib/context/basic_test.js
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator, __dirname */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var L20n = {
|
||||
getContext: function() {
|
||||
return new L10n.Context();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var L20n = require('../../../src/bindings/node');
|
||||
}
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var path =
|
||||
'app://sharedtest.gaiamobile.org/test/unit/l10n/lib/context';
|
||||
} else {
|
||||
var path = __dirname;
|
||||
}
|
||||
|
||||
describe('A simple context with one resource', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = L20n.getContext();
|
||||
ctx.resLinks.push(path + '/fixtures/basic.properties');
|
||||
ctx.ready(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should return the string value of brandName', function() {
|
||||
var value = ctx.get('brandName');
|
||||
assert.strictEqual(value, 'Firefox');
|
||||
});
|
||||
|
||||
it('should return the value of about with the value' +
|
||||
' of brandName in it', function() {
|
||||
var value = ctx.get('about');
|
||||
assert.strictEqual(value, 'About Firefox');
|
||||
});
|
||||
|
||||
it('should return the value of cert with the value of ' +
|
||||
'organization passed directly', function() {
|
||||
var value = ctx.get('cert', {organization: 'Mozilla Foundation'});
|
||||
assert.strictEqual(value, 'Certificate signed by Mozilla Foundation');
|
||||
});
|
||||
|
||||
it('should return the correct plural form for 0', function() {
|
||||
var value = ctx.get('unreadMessages', {unread: 0});
|
||||
assert.strictEqual(value, '0 unread');
|
||||
});
|
||||
|
||||
it('should return the correct plural form for 1', function() {
|
||||
var value = ctx.get('unreadMessages', {unread: 1});
|
||||
assert.strictEqual(value, 'One unread');
|
||||
});
|
||||
|
||||
it('should return the correct plural form for 2', function() {
|
||||
var value = ctx.get('unreadMessages', {unread: 2});
|
||||
assert.strictEqual(value, '2 unread');
|
||||
});
|
||||
|
||||
it('should return the correct plural form for 3', function() {
|
||||
var value = ctx.get('unreadMessages', {unread: 3});
|
||||
assert.strictEqual(value, '3 unread');
|
||||
});
|
||||
});
|
||||
110
gaia/apps/sharedtest/test/unit/l10n/lib/context/fallback_test.js
Executable file
110
gaia/apps/sharedtest/test/unit/l10n/lib/context/fallback_test.js
Executable file
|
|
@ -0,0 +1,110 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator, __dirname */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
var path =
|
||||
'app://sharedtest.gaiamobile.org/test/unit/l10n/lib/context';
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
var path = __dirname;
|
||||
}
|
||||
|
||||
describe('One fallback locale', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US', ['pl']);
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
|
||||
describe('Translation in the first locale exists and is OK', function() {
|
||||
it('[e]', function() {
|
||||
assert.strictEqual(ctx.get('e'), 'E pl');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in first locale', function() {
|
||||
describe('Entity exists in second locale:', function() {
|
||||
it('[ve]', function() {
|
||||
assert.strictEqual(ctx.get('ve'), 'VE {{ boo }} pl');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale:', function() {
|
||||
it('[vv]', function() {
|
||||
assert.strictEqual(ctx.get('vv'), 'VV {{ boo }} pl');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale:', function() {
|
||||
it('[vi]', function() {
|
||||
assert.strictEqual(ctx.get('vi'), 'VI {{ boo }} pl');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[vm]', function() {
|
||||
assert.strictEqual(ctx.get('vm'), 'VM {{ boo }} pl');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in first locale', function() {
|
||||
describe('Entity exists in second locale', function() {
|
||||
it('[ie]', function() {
|
||||
assert.strictEqual(ctx.get('ie'), 'ie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale', function() {
|
||||
it('[iv]', function() {
|
||||
assert.strictEqual(ctx.get('iv'), 'iv');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale', function() {
|
||||
it('[ii]', function() {
|
||||
assert.strictEqual(ctx.get('ii'), 'ii');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[im]', function() {
|
||||
assert.strictEqual(ctx.get('im'), 'im');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity not found in first locale', function() {
|
||||
describe('Entity exists in second locale:', function() {
|
||||
it('[me]', function() {
|
||||
assert.strictEqual(ctx.get('me'), 'ME en-US');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale:', function() {
|
||||
it('[mv]', function() {
|
||||
assert.strictEqual(ctx.get('mv'), 'MV {{ boo }} en-US');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale:', function() {
|
||||
it('[mi]', function() {
|
||||
assert.strictEqual(ctx.get('mi'), 'mi');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[mm]', function() {
|
||||
assert.strictEqual(ctx.get('mm'), '');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
brandName=Firefox
|
||||
about=About {{ brandName }}
|
||||
cert=Certificate signed by {{ organization }}
|
||||
unreadMessages={[plural(unread)]}
|
||||
unreadMessages[one]=One unread
|
||||
unreadMessages[other]={{unread}} unread
|
||||
57
gaia/apps/sharedtest/test/unit/l10n/lib/context/fixtures/en-US.properties
Executable file
57
gaia/apps/sharedtest/test/unit/l10n/lib/context/fixtures/en-US.properties
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
foo=Foo en-US
|
||||
|
||||
# e - existing
|
||||
# v - ValueError
|
||||
# i - IndexError
|
||||
# m - missing
|
||||
|
||||
me=ME en-US
|
||||
mv=MV {{ boo }} en-US
|
||||
mi={[plural(boo)]}
|
||||
mi[key]=MI en-US
|
||||
|
||||
vve=VVE en-US
|
||||
vvv=VVV {{ boo }} en-US
|
||||
<vvi[boo] { key: "VVI en-US" }>
|
||||
|
||||
vie=VIE en-US
|
||||
viv=VIV {{ boo }} en-US
|
||||
vii={[plural(boo)]}
|
||||
vii[key]=VII en-US
|
||||
|
||||
vme=VME en-US
|
||||
vmv=VMV {{ boo }} en-US
|
||||
vmi={[plural(boo)]}
|
||||
vmi[key]=VMI en-US
|
||||
|
||||
|
||||
ive=IVE en-US
|
||||
ivv=IVV {{ boo }} en-US
|
||||
ivi={[plural(boo)]}
|
||||
ivi[key]=IVI en-US
|
||||
|
||||
iie=IIE en-US
|
||||
iiv=IIV {{ boo }} en-US
|
||||
iii={[plural(boo)]}
|
||||
iii[key]=III en-US
|
||||
|
||||
ime=IME en-US
|
||||
imv=IMV {{ boo }} en-US
|
||||
imi={[plural(boo)]}
|
||||
imi[key]=IMI en-US
|
||||
|
||||
|
||||
mve=MVE en-US
|
||||
mvv=MVV {{ boo }} en-US
|
||||
mvi={[plural(boo)]}
|
||||
mvi[key]=MVI en-US
|
||||
|
||||
mie=MIE en-US
|
||||
miv=MIV {{ boo }} en-US
|
||||
mii={[plural(boo)]}
|
||||
mii[key]=MII en-US
|
||||
|
||||
mme=MME en-US
|
||||
mmv=MMV {{ boo }} en-US
|
||||
mmi={[plural(boo)]}
|
||||
mmi[key]=MMI en-US
|
||||
69
gaia/apps/sharedtest/test/unit/l10n/lib/context/fixtures/pl.properties
Executable file
69
gaia/apps/sharedtest/test/unit/l10n/lib/context/fixtures/pl.properties
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
foo=Foo pl
|
||||
|
||||
# e - existing
|
||||
# v - ValueError
|
||||
# i - IndexError
|
||||
# m - missing
|
||||
|
||||
e=E pl
|
||||
v=V {{ boo }} pl
|
||||
i={[plural(boo)]}
|
||||
i[key]=i pl
|
||||
|
||||
|
||||
ve=VE {{ boo }} pl
|
||||
vv=VV {{ boo }} pl
|
||||
vi=VI {{ boo }} pl
|
||||
vm=VM {{ boo }} pl
|
||||
|
||||
ie={[plural(boo)]}
|
||||
ie[key]=IE pl
|
||||
iv={[plural(boo)]}
|
||||
iv[key]=IV pl
|
||||
ii={[plural(boo)]}
|
||||
ii[key]=II pl
|
||||
im={[plural(boo)]}
|
||||
im[key]=IM pl
|
||||
|
||||
|
||||
vve=VVE {{ boo }} pl
|
||||
vvv=VVV {{ boo }} pl
|
||||
vvi=VVI {{ boo }} pl
|
||||
vvm=VVM {{ boo }} pl
|
||||
|
||||
vie=VIE {{ boo }} pl
|
||||
viv=VIV {{ boo }} pl
|
||||
vii=VII {{ boo }} pl
|
||||
vim=VIM {{ boo }} pl
|
||||
|
||||
vme=VME {{ boo }} pl
|
||||
vmv=VMV {{ boo }} pl
|
||||
vmi=VMI {{ boo }} pl
|
||||
vmm=VMM {{ boo }} pl
|
||||
|
||||
ive={[plural(boo)]}
|
||||
ive[key]=IVE pl
|
||||
ivv={[plural(boo)]}
|
||||
ivv[key]=IVV pl
|
||||
ivi={[plural(boo)]}
|
||||
ivi[key]=IVI pl
|
||||
ivm={[plural(boo)]}
|
||||
ivm[key]=IVM pl
|
||||
|
||||
iie={[plural(boo)]}
|
||||
iie[key]=IIE pl
|
||||
iiv={[plural(boo)]}
|
||||
iiv[key]=IIV pl
|
||||
iii={[plural(boo)]}
|
||||
iii[key]=III pl
|
||||
iim={[plural(boo)]}
|
||||
iim[key]=IIM pl
|
||||
|
||||
ime={[plural(boo)]}
|
||||
ime[key]=IME pl
|
||||
imv={[plural(boo)]}
|
||||
imv[key]=IMV pl
|
||||
imi={[plural(boo)]}
|
||||
imi[key]=IMI pl
|
||||
imm={[plural(boo)]}
|
||||
imm[key]=IMM pl
|
||||
116
gaia/apps/sharedtest/test/unit/l10n/lib/context/format_test.js
Executable file
116
gaia/apps/sharedtest/test/unit/l10n/lib/context/format_test.js
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator, __dirname */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
var path =
|
||||
'app://sharedtest.gaiamobile.org/test/unit/l10n/lib/context';
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
var path = __dirname;
|
||||
}
|
||||
|
||||
function assertPromise(promise, expected, done) {
|
||||
promise.then(function(value) {
|
||||
assert.strictEqual(value, expected);
|
||||
}).then(done, done);
|
||||
}
|
||||
|
||||
describe('One fallback locale', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US', ['pl']);
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
|
||||
describe('Translation in the first locale exists and is OK', function() {
|
||||
it('[e]', function(done) {
|
||||
assertPromise(ctx.formatValue('e'), 'E pl', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in first locale', function() {
|
||||
describe('Entity exists in second locale:', function() {
|
||||
it('[ve]', function(done) {
|
||||
assertPromise(ctx.formatValue('ve'), 'VE {{ boo }} pl', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale:', function() {
|
||||
it('[vv]', function(done) {
|
||||
assertPromise(ctx.formatValue('vv'), 'VV {{ boo }} pl', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale:', function() {
|
||||
it('[vi]', function(done) {
|
||||
assertPromise(ctx.formatValue('vi'), 'VI {{ boo }} pl', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[vm]', function(done) {
|
||||
assertPromise(ctx.formatValue('vm'), 'VM {{ boo }} pl', done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in first locale', function() {
|
||||
describe('Entity exists in second locale', function() {
|
||||
it('[ie]', function(done) {
|
||||
assertPromise(ctx.formatValue('ie'), 'ie', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale', function() {
|
||||
it('[iv]', function(done) {
|
||||
assertPromise(ctx.formatValue('iv'), 'iv', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale', function() {
|
||||
it('[ii]', function(done) {
|
||||
assertPromise(ctx.formatValue('ii'), 'ii', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[im]', function(done) {
|
||||
assertPromise(ctx.formatValue('im'), 'im', done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity not found in first locale', function() {
|
||||
describe('Entity exists in second locale:', function() {
|
||||
it('[me]', function(done) {
|
||||
assertPromise(ctx.formatValue('me'), 'ME en-US', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ValueError in second locale:', function() {
|
||||
it('[mv]', function(done) {
|
||||
assertPromise(ctx.formatValue('mv'), 'MV {{ boo }} en-US', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexError in second locale:', function() {
|
||||
it('[mi]', function(done) {
|
||||
assertPromise(ctx.formatValue('mi'), 'mi', done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Entity missing in second locale:', function() {
|
||||
it('[mm]', function(done) {
|
||||
assertPromise(ctx.formatValue('mm'), 'mm', done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
59
gaia/apps/sharedtest/test/unit/l10n/lib/context/langnego_test.js
Executable file
59
gaia/apps/sharedtest/test/unit/l10n/lib/context/langnego_test.js
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
}
|
||||
|
||||
describe('Language negotiation without arguments', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('used the en-US locale', function() {
|
||||
assert.strictEqual(ctx.supportedLocales.length, 1);
|
||||
assert.strictEqual(ctx.supportedLocales[0], 'en-US');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Language negotiation with arguments', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US', ['pl']);
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
|
||||
it('sets the correct fallback chain', function() {
|
||||
assert.strictEqual(ctx.supportedLocales.length, 2);
|
||||
assert.strictEqual(ctx.supportedLocales[0], 'pl');
|
||||
assert.strictEqual(ctx.supportedLocales[1], 'en-US');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Language negotiation with arguments and unsupported', function() {
|
||||
var ctx;
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US', ['pl']);
|
||||
ctx.requestLocales('fr', 'pl');
|
||||
});
|
||||
it('sets the correct fallback chain', function() {
|
||||
assert.strictEqual(ctx.supportedLocales.length, 2);
|
||||
assert.strictEqual(ctx.supportedLocales[0], 'pl');
|
||||
assert.strictEqual(ctx.supportedLocales[1], 'en-US');
|
||||
});
|
||||
});
|
||||
145
gaia/apps/sharedtest/test/unit/l10n/lib/context/loading_test.js
Executable file
145
gaia/apps/sharedtest/test/unit/l10n/lib/context/loading_test.js
Executable file
|
|
@ -0,0 +1,145 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator, __dirname */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
var path =
|
||||
'app://sharedtest.gaiamobile.org/test/unit/l10n/lib/context';
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
var path = __dirname;
|
||||
}
|
||||
|
||||
describe('A non-loading context', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function() {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
});
|
||||
|
||||
it('should throw on get', function() {
|
||||
assert.throws(function(){
|
||||
ctx.get('dummy');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
it('should throw on getEntity', function() {
|
||||
assert.throws(function(){
|
||||
ctx.getEntity('dummy');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('A loading, non-ready context', function() {
|
||||
var ctx;
|
||||
beforeEach(function() {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should throw on requestLocales', function() {
|
||||
assert.throws(function(){
|
||||
ctx.requestLocales('en-US');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
it('should throw on get', function() {
|
||||
assert.throws(function(){
|
||||
ctx.get('dummy');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
it('should throw on getEntity', function() {
|
||||
assert.throws(function(){
|
||||
ctx.getEntity('dummy');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
it('should throw on requestLocales', function() {
|
||||
assert.throws(function(){
|
||||
ctx.requestLocales('en-US');
|
||||
}, /Context not ready/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('A loading, ready context', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should not throw on get of a known entity', function() {
|
||||
assert.doesNotThrow(function(){
|
||||
ctx.get('foo');
|
||||
});
|
||||
assert.strictEqual(ctx.get('foo'), 'Foo en-US');
|
||||
});
|
||||
|
||||
it('should not throw on get of an unknown entity', function() {
|
||||
assert.doesNotThrow(function(){
|
||||
ctx.get('missing');
|
||||
});
|
||||
assert.strictEqual(ctx.get('missing'), '');
|
||||
});
|
||||
|
||||
it('should not throw on getEntity of a known entity', function() {
|
||||
assert.doesNotThrow(function(){
|
||||
ctx.getEntity('foo');
|
||||
});
|
||||
assert.strictEqual(ctx.getEntity('foo').value, 'Foo en-US');
|
||||
});
|
||||
|
||||
it('should not throw on getEntity of an unknown entity', function() {
|
||||
assert.doesNotThrow(function(){
|
||||
ctx.getEntity('missing');
|
||||
});
|
||||
assert.strictEqual(ctx.getEntity('missing'), '');
|
||||
});
|
||||
|
||||
it('should not throw on requestLocales', function(done) {
|
||||
ctx.once(function() {
|
||||
assert.strictEqual(ctx.isReady, true);
|
||||
done();
|
||||
});
|
||||
assert.doesNotThrow(function(){
|
||||
ctx.requestLocales('pl', 'en-US');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('A loading, ready context', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/{locale}.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should return translations for the built fallback chain ', function() {
|
||||
// Bug 942183 - Error when localizeNode is done quickly after
|
||||
// requestLocales https://bugzil.la/942183
|
||||
// Changing locales triggers the build process for the 'pl' locale.
|
||||
// However, synchronous methods called right after the change should still
|
||||
// return translations for the previous fallback chain
|
||||
ctx.requestLocales('pl');
|
||||
assert.strictEqual(ctx.get('foo'), 'Foo en-US');
|
||||
});
|
||||
|
||||
});
|
||||
49
gaia/apps/sharedtest/test/unit/l10n/lib/context/resources_test.js
Executable file
49
gaia/apps/sharedtest/test/unit/l10n/lib/context/resources_test.js
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/* global assert:true, it, describe, beforeEach */
|
||||
/* global navigator, __dirname */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
var path = 'app://sharedtest.gaiamobile.org/test/unit/l10n/context';
|
||||
} else {
|
||||
var assert = require('assert');
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
var path = __dirname;
|
||||
}
|
||||
|
||||
describe('Missing resources', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/en-US.properties');
|
||||
ctx.resLinks.push(path + '/fixtures/missing.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should get ready', function() {
|
||||
assert.strictEqual(ctx.isReady, true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('No valid resources', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function(done) {
|
||||
ctx = new Context();
|
||||
ctx.resLinks.push(path + '/fixtures/missing.properties');
|
||||
ctx.resLinks.push(path + '/fixtures/another.properties');
|
||||
ctx.once(done);
|
||||
ctx.registerLocales('en-US');
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should get ready', function() {
|
||||
assert.strictEqual(ctx.isReady, true);
|
||||
});
|
||||
|
||||
});
|
||||
66
gaia/apps/sharedtest/test/unit/l10n/lib/context/retranslation_test.js
Executable file
66
gaia/apps/sharedtest/test/unit/l10n/lib/context/retranslation_test.js
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
/* global it, describe, beforeEach */
|
||||
/* global navigator */
|
||||
'use strict';
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
var L10n = navigator.mozL10n._getInternalAPI();
|
||||
var Context = L10n.Context;
|
||||
} else {
|
||||
var Context = require('../../../src/lib/context').Context;
|
||||
}
|
||||
|
||||
describe('ctx.ready', function() {
|
||||
var ctx;
|
||||
|
||||
beforeEach(function() {
|
||||
ctx = new Context();
|
||||
ctx.registerLocales('en-US', ['pl']);
|
||||
});
|
||||
|
||||
it('should fire asynchronously when context is ready', function(done) {
|
||||
ctx.ready(function() {
|
||||
done();
|
||||
});
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
|
||||
it('should fire asynchronously when language changes', function(done) {
|
||||
var now = false;
|
||||
ctx.ready(function() {
|
||||
if (now) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
ctx.once(function() {
|
||||
now = true;
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should fire synchronously when context is ready', function(done) {
|
||||
ctx.once(function() {
|
||||
ctx.ready(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
it('should fire synchronously when language changes', function(done) {
|
||||
var now = false;
|
||||
ctx.once(function() {
|
||||
ctx.ready(function() {
|
||||
if (now) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
now = true;
|
||||
ctx.requestLocales('pl');
|
||||
});
|
||||
});
|
||||
ctx.requestLocales('en-US');
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue