Permalink
Browse files

reorganised tests

  • Loading branch information...
jamuhl committed Feb 12, 2013
1 parent 658ac65 commit b17691b0f48d74e7400e98c2961f679591b8a96d
Showing with 1,753 additions and 1,660 deletions.
  1. +8 −2 release/i18next-1.5.11pre.js
  2. BIN release/i18next-1.5.11pre.zip
  3. +8 −2 release/i18next.amd-1.5.11pre.js
  4. BIN release/i18next.amd-1.5.11pre.zip
  5. +8 −2 release/i18next.amd.withJQuery-1.5.11pre.js
  6. +1 −0 releasenotes.md
  7. +0 −164 spec/functions.basic.spec.js
  8. +11 −0 spec/functions.spec.js
  9. +0 −541 spec/functions.translation.spec.js
  10. +68 −0 spec/functions/functions.postmissing.spec.js
  11. +44 −0 spec/functions/functions.postprocessor.spec.js
  12. +23 −0 spec/functions/functions.preload.spec.js
  13. +22 −0 spec/functions/functions.setlng.spec.js
  14. +8 −495 spec/init.spec.js
  15. +23 −0 spec/init/init.addResourceBundle.spec.js
  16. +67 −0 spec/init/init.load.spec.js
  17. +88 −0 spec/init/init.loadBehaviour.spec.js
  18. +59 −0 spec/init/init.localstorage.spec.js
  19. +149 −0 spec/init/init.namespace.spec.js
  20. +34 −0 spec/init/init.preload.spec.js
  21. +13 −0 spec/init/init.syncFlag.spec.js
  22. +62 −0 spec/init/init.varia.spec.js
  23. +3 −181 spec/jquery.spec.js
  24. +37 −0 spec/jquery/jquery.deferred.spec.js
  25. +153 −0 spec/jquery/jquery.i18nFunction.spec.js
  26. +13 −0 spec/jquery/jquery.varia.spec.js
  27. +2 −2 spec/spec.js
  28. +25 −0 spec/translate.spec.js
  29. +16 −0 spec/translate/translate.arrayValue.spec.js
  30. +77 −0 spec/translate/translate.context.spec.js
  31. +16 −0 spec/translate/translate.emptyValue.spec.js
  32. +102 −0 spec/translate/translate.interpolation.spec.js
  33. +37 −0 spec/translate/translate.nesting.spec.js
  34. +73 −0 spec/translate/translate.objectValue.spec.js
  35. +159 −0 spec/translate/translate.plurals.spec.js
  36. +21 −0 spec/translate/translate.setlng.spec.js
  37. +24 −0 spec/translate/translate.sprintf.spec.js
  38. +8 −2 src/i18next.jquery.js
  39. +291 −269 test/test.js
@@ -723,6 +723,12 @@
var key = ele.attr(o.selectorAttr);
if (!key) return;
+ var target = ele
+ , targetSelector = ele.data("i18n-target");
+ if (targetSelector) {
+ target = ele.find(targetSelector) || ele;
+ }
+
if (!options && o.useDataAttrOptions === true) {
options = ele.data("i18n-options");
}
@@ -732,11 +738,11 @@
var keys = key.split(';');
$.each(keys, function(m, k) {
- parse(ele, k, options);
+ parse(target, k, options);
});
} else {
- parse(ele, k, options);
+ parse(target, k, options);
}
if (o.useDataAttrOptions === true) ele.data("i18n-options", options);
Binary file not shown.
@@ -719,6 +719,12 @@
var key = ele.attr(o.selectorAttr);
if (!key) return;
+ var target = ele
+ , targetSelector = ele.data("i18n-target");
+ if (targetSelector) {
+ target = ele.find(targetSelector) || ele;
+ }
+
if (!options && o.useDataAttrOptions === true) {
options = ele.data("i18n-options");
}
@@ -728,11 +734,11 @@
var keys = key.split(';');
$.each(keys, function(m, k) {
- parse(ele, k, options);
+ parse(target, k, options);
});
} else {
- parse(ele, k, options);
+ parse(target, k, options);
}
if (o.useDataAttrOptions === true) ele.data("i18n-options", options);
Binary file not shown.
@@ -720,6 +720,12 @@
var key = ele.attr(o.selectorAttr);
if (!key) return;
+ var target = ele
+ , targetSelector = ele.data("i18n-target");
+ if (targetSelector) {
+ target = ele.find(targetSelector) || ele;
+ }
+
if (!options && o.useDataAttrOptions === true) {
options = ele.data("i18n-options");
}
@@ -729,11 +735,11 @@
var keys = key.split(';');
$.each(keys, function(m, k) {
- parse(ele, k, options);
+ parse(target, k, options);
});
} else {
- parse(ele, k, options);
+ parse(target, k, options);
}
if (o.useDataAttrOptions === true) ele.data("i18n-options", options);
View
@@ -1,4 +1,5 @@
### 1.5.11pre
+- option to specify target to set attributes with jquery function by using 'data-i18n-target attribute'
- function to set new options for nesting functionality
- function to add resources after init
- option to lookup in default namespace if value is not found in given namespace
@@ -1,164 +0,0 @@
-describe('basic functionality', function() {
-
- describe('setting language', function() {
-
- beforeEach(function(done) {
- i18n.init( $.extend(opts, {
- resStore: {
- 'en-US': { translation: { 'simpleTest': 'ok_from_en-US' } },
- 'de-DE': { translation: { 'simpleTest': 'ok_from_de-DE' } }
- }
- }), function(t) { done(); } );
- });
-
- it('it should provide resources for set language', function(done) {
- expect(i18n.t('simpleTest')).to.be('ok_from_en-US');
-
- i18n.setLng('de-DE', function(t) {
- expect(t('simpleTest')).to.be('ok_from_de-DE');
- done();
- });
-
- });
-
- });
-
- describe('preloading multiple languages', function() {
-
- var spy;
-
- beforeEach(function(done) {
- spy = sinon.spy(i18n.sync, '_fetchOne');
- i18n.init(opts, function(t) { done(); });
- });
-
- afterEach(function() {
- spy.restore();
- });
-
- it('it should preload resources for languages', function(done) {
- spy.reset();
- i18n.preload('de-DE', function(t) {
- expect(spy.callCount).to.be(5); // en-US, en, de-DE, de, dev
- done();
- });
-
- });
-
- });
-
- describe('postprocessing tranlation', function() {
-
- describe('having a postprocessor', function() {
-
- before(function(){
- i18n.addPostProcessor('myProcessor', function(val, key, opts) {
- return 'ok_from_postprocessor';
- });
- });
-
- beforeEach(function(done) {
- i18n.init( $.extend(opts, {
- resStore: {
- 'en-US': { translation: { 'simpleTest': 'ok_from_en-US' } },
- 'de-DE': { translation: { 'simpleTest': 'ok_from_de-DE' } }
- }
- }), function(t) { done(); } );
- });
-
- it('it should postprocess the translation by passing in postProcess name to t function', function() {
- expect(i18n.t('simpleTest', {postProcess: 'myProcessor'})).to.be('ok_from_postprocessor');
- });
-
- describe('or setting it as default on init', function() {
-
- beforeEach(function(done) {
- i18n.init( $.extend(opts, {
- resStore: {
- 'en-US': { translation: { 'simpleTest': 'ok_from_en-US' } },
- 'de-DE': { translation: { 'simpleTest': 'ok_from_de-DE' } }
- },
- postProcess: 'myProcessor'
- }), function(t) { done(); } );
- });
-
- it('it should postprocess the translation by default', function() {
- expect(i18n.t('simpleTest')).to.be('ok_from_postprocessor');
- });
-
- });
-
- });
-
- });
-
- describe('post missing resources', function() {
-
- describe('to fallback', function() {
- var server, stub;
-
- beforeEach(function(done) {
- server = sinon.fakeServer.create();
- stub = sinon.stub(i18n.functions, "ajax");
-
- server.respondWith([200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"]);
-
- i18n.init( $.extend(opts, {
- sendMissing: true,
- resStore: {
- 'en-US': { translation: { } },
- 'en': { translation: { } },
- 'dev': { translation: { } }
- }
- }), function(t) { done(); } );
- });
-
- afterEach(function() {
- server.restore();
- stub.restore();
- });
-
- it('it should post missing resource to server', function() {
- i18n.t('missing');
- server.respond();
- expect(stub.calledOnce).to.be(true);
- });
-
- });
-
- describe('to all', function() {
- var server, stub;
-
- beforeEach(function(done) {
- server = sinon.fakeServer.create();
- stub = sinon.stub(i18n.functions, "ajax");
-
- server.respondWith([200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"]);
-
- i18n.init( $.extend(opts, {
- sendMissing: true,
- sendMissingTo: 'all',
- resStore: {
- 'en-US': { translation: { } },
- 'en': { translation: { } },
- 'dev': { translation: { } }
- }
- }), function(t) { done(); } );
- });
-
- afterEach(function() {
- server.restore();
- stub.restore();
- });
-
- it('it should post missing resource for all lng to server', function() {
- i18n.t('missing');
- server.respond();
- expect(stub.calledThrice).to.be(true);
- });
-
- });
-
- });
-
-});
View
@@ -0,0 +1,11 @@
+describe('basic functionality', function() {
+
+ //= functions/functions.setlng.spec.js
+
+ //= functions/functions.preload.spec.js
+
+ //= functions/functions.postprocessor.spec.js
+
+ //= functions/functions.postmissing.spec.js
+
+});
Oops, something went wrong.

0 comments on commit b17691b

Please sign in to comment.