Browse files

added check that getCompiledData has locale param

  • Loading branch information...
1 parent 12fdc46 commit a973e1bd37b5e40d7e3921d2800840f90951fd23 @puzrin puzrin committed Dec 31, 2012
Showing with 9 additions and 0 deletions.
  1. +4 −0 lib/babelfish.js
  2. +5 −0 test/babelfish-test.js
View
4 lib/babelfish.js
@@ -416,6 +416,10 @@ BabelFish.prototype.t = BabelFish.prototype.translate;
BabelFish.prototype.getCompiledData = function getCompiledData(locale, phrase) {
var storage;
+ if (!locale) {
+ throw new Error('You must specify locale');
+ }
+
// force recompilation if needed
if (!this._compiled[locale]) {
recompile(this, locale);
View
5 test/babelfish-test.js
@@ -219,6 +219,11 @@ describe('BabelFish', function () {
expect(data['test.complex.variable'].type)
.is.equal('function');
});
+
+ it('`getCompiledData()` throws error if locale missed', function () {
+ expect(function () { b.getCompiledData(); })
+ .to.throws(Error);
+ });
});

0 comments on commit a973e1b

Please sign in to comment.