Created
January 25, 2013 19:20
-
-
Save mixonic/4637044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit 3fb6fb00626201fd096b2d8313178e393e0b5903 | |
| Author: Matthew Beale <[email protected]> | |
| Date: Fri Jan 25 14:15:57 2013 -0500 | |
| Add tests for #1866 - loc helper | |
| diff --git a/packages/ember-handlebars/lib/helpers/loc.js b/packages/ember-handlebars/lib/helpers/loc.js | |
| index d2d1f8b..7b023f5 100644 | |
| --- a/packages/ember-handlebars/lib/helpers/loc.js | |
| +++ b/packages/ember-handlebars/lib/helpers/loc.js | |
| @@ -15,6 +15,9 @@ require('ember-handlebars/ext'); | |
| </script> | |
| ``` | |
| + Take note that `welcome` is a string and not an object | |
| + reference. | |
| + | |
| @method loc | |
| @for Ember.Handlebars.helpers | |
| @param {String} str The string to format | |
| diff --git a/packages/ember-handlebars/tests/helpers/loc_test.js b/packages/ember-handlebars/tests/helpers/loc_test.js | |
| new file mode 100644 | |
| index 0000000..f681b17 | |
| --- /dev/null | |
| +++ b/packages/ember-handlebars/tests/helpers/loc_test.js | |
| @@ -0,0 +1,51 @@ | |
| +var buildView = function(template, context) { | |
| + return Ember.View.create({ | |
| + template: Ember.Handlebars.compile(template), | |
| + context: (context || {}) | |
| + }); | |
| +}; | |
| + | |
| +var appendView = function(view) { | |
| + Ember.run(function() { | |
| + view.appendTo('#qunit-fixture'); | |
| + }); | |
| +}; | |
| + | |
| +var destroyView = function(view) { | |
| + Ember.run(function(){ | |
| + view.destroy(); | |
| + }); | |
| +}; | |
| + | |
| +var oldString; | |
| + | |
| +module('Handlebars {{loc valueToLocalize}} helper', { | |
| + setup: function() { | |
| + oldString = Ember.STRINGS; | |
| + Ember.STRINGS = { | |
| + '_Howdy Friend': 'Hallo Freund' | |
| + }; | |
| + }, | |
| + | |
| + teardown: function() { | |
| + Ember.STRINGS = oldString; | |
| + } | |
| +}); | |
| + | |
| +test("let the original value through by default", function() { | |
| + var view = buildView('{{loc "Hiya buddy!"}}'); | |
| + appendView(view); | |
| + | |
| + equal(view.$().text(), "Hiya buddy!"); | |
| + | |
| + destroyView(view); | |
| +}); | |
| + | |
| +test("localize a simple string", function() { | |
| + var view = buildView('{{loc "_Howdy Friend"}}'); | |
| + appendView(view); | |
| + | |
| + equal(view.$().text(), "Hallo Freund"); | |
| + | |
| + destroyView(view); | |
| +}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment