clear locale on each spec run, fix indentation
This commit is contained in:
parent
1f98e1c639
commit
a2aff720a2
2 changed files with 86 additions and 63 deletions
|
|
@ -2,7 +2,8 @@
|
||||||
* licensed under the Affero General Public License version 3 or later. See
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
Diaspora.I18n = {
|
|
||||||
|
Diaspora.I18n = {
|
||||||
language: "en",
|
language: "en",
|
||||||
locale: {},
|
locale: {},
|
||||||
|
|
||||||
|
|
@ -35,5 +36,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.template(translatedMessage, views || {});
|
return _.template(translatedMessage, views || {});
|
||||||
|
},
|
||||||
|
|
||||||
|
reset: function() {
|
||||||
|
this.locale = {};
|
||||||
|
|
||||||
|
if( arguments.length > 0 && !(_.isEmpty(arguments[0])) )
|
||||||
|
this.locale = arguments[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,7 @@
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe("Diaspora", function() {
|
describe("Diaspora.I18n", function() {
|
||||||
describe("widgets", function() {
|
|
||||||
describe("i18n", function() {
|
|
||||||
var locale = {namespace: {
|
var locale = {namespace: {
|
||||||
message: "hey",
|
message: "hey",
|
||||||
template: "<%= myVar %>",
|
template: "<%= myVar %>",
|
||||||
|
|
@ -22,7 +20,11 @@ describe("Diaspora", function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("loadLocale", function() {
|
beforeEach(function(){
|
||||||
|
Diaspora.I18n.reset(); // run tests with clean locale
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("::loadLocale", function() {
|
||||||
it("sets the class's locale variable", function() {
|
it("sets the class's locale variable", function() {
|
||||||
Diaspora.I18n.loadLocale(locale);
|
Diaspora.I18n.loadLocale(locale);
|
||||||
|
|
||||||
|
|
@ -40,7 +42,7 @@ describe("Diaspora", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("t", function() {
|
describe("::t", function() {
|
||||||
var translation;
|
var translation;
|
||||||
beforeEach(function() { Diaspora.I18n.loadLocale(locale); });
|
beforeEach(function() { Diaspora.I18n.loadLocale(locale); });
|
||||||
|
|
||||||
|
|
@ -66,6 +68,19 @@ describe("Diaspora", function() {
|
||||||
expect(Diaspora.I18n.t("missing.locale")).toEqual("");
|
expect(Diaspora.I18n.t("missing.locale")).toEqual("");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("::reset", function(){
|
||||||
|
it("clears the current locale", function() {
|
||||||
|
Diaspora.I18n.loadLocale(locale);
|
||||||
|
Diaspora.I18n.reset()
|
||||||
|
expect(Diaspora.I18n.locale).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("sets the locale to only a specific value", function() {
|
||||||
|
var data = { some: 'value' };
|
||||||
|
Diaspora.I18n.loadLocale(locale);
|
||||||
|
Diaspora.I18n.reset(data);
|
||||||
|
expect(Diaspora.I18n.locale).toEqual(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue