Skip to content

Commit

Permalink
STRF-9658 logger accepts strings instead of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jairo-bc committed Mar 2, 2022
1 parent 48ff533 commit 40c1508
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/translator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Translator.prototype.translate = function (key, parameters) {
try {
return this._formatFunctions[key](parameters);
} catch (err) {
this._logger.error(err);
this._logger.error(err.message);
return '';
}
};
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe('Translator', () => {

expect(translator.translate('hello')).to.equal('');
expect(loggerStub.error.called).to.equal(true);
expect(loggerStub.error.getCall(0).args[0]).to.equal("MessageFormat: Data required for 'name'.")

done();
});
Expand All @@ -143,8 +144,10 @@ describe('Translator', () => {
}, loggerStub);

const result = translator.translate('items_with_syntax_error', { count: 1 });
const errMessage = 'Language File Syntax Error: Expected "plural" or "select" but "p" found. for key "items_with_syntax_error"';
expect(result).to.equal("");
expect(loggerStub.error.called).to.equal(true);
expect(loggerStub.error.getCall(0).args[0]).to.equal(errMessage);

done();
});
Expand Down

0 comments on commit 40c1508

Please sign in to comment.