diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index eb5b3b689..fd769550e 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -22,6 +22,7 @@ src_files: - public/javascripts/diaspora.js - public/javascripts/widgets/alert.js - public/javascripts/widgets/embedder.js + - public/javascripts/widgets/i18n.js - public/javascripts/mobile.js - public/javascripts/aspect-edit.js - public/javascripts/aspect-contacts.js diff --git a/spec/javascripts/widget-i18n-spec.js b/spec/javascripts/widget-i18n-spec.js new file mode 100644 index 000000000..ddecc2276 --- /dev/null +++ b/spec/javascripts/widget-i18n-spec.js @@ -0,0 +1,45 @@ +/** + * Created by . + * User: dan + * Date: Jan 27, 2011 + * Time: 3:20:57 PM + * To change this template use File | Settings | File Templates. + */ +describe("Diaspora", function() { + beforeEach(function() { + Diaspora.widgets.i18n.loadLocale(null/* TODO: spec.retrieveFixture("locale")*/, "en"); + }); + describe("widgets", function() { + describe("i18n", function() { + describe("loadLocale", function() { + it("sets the class's locale variable", function() { + Diaspora.widgets.i18n.loadLocale({sup: "hi"}); + expect(Diaspora.widgets.i18n.locale).toEqual({sup: "hi"}); + }); + }); + describe("t", function() { + it("returns the specified translation", function() { + Diaspora.widgets.i18n.loadLocale({yo: "sup"}, "en"); + var translation = Diaspora.widgets.i18n.t("yo"); + expect(translation).toEqual("sup"); + }); + it("will go through a infinitely deep object", function() { + Diaspora.widgets.i18n.loadLocale({ + yo: { + hi: { + sup: { + test: "test" + } + } + }, + more: { + another: "i hope this spec is green" + } + }); + expect(Diaspora.widgets.i18n.t("yo.hi.sup.test")).toEqual("test"); + expect(Diaspora.widgets.i18n.t("more.another")).toEqual("i hope this spec is green"); + }); + }); + }); + }); +}); \ No newline at end of file