Permalink
Browse files

fix(relative-time): error on missing lng

if the lng option is not provided, throw a custom error message

#234
  • Loading branch information...
zewa666 committed Oct 16, 2017
1 parent 73096d4 commit 5deb4d284bcf1f93f855d2582275946bdf4bfa12
Showing with 13 additions and 0 deletions.
  1. +4 −0 src/i18n.js
  2. +9 −0 test/unit/relative.time.spec.js
View
@@ -35,6 +35,10 @@ export class I18N {
debug: false
};
if (options && !options.lng) {
throw new Error('You need to provide the lng option');
}
i18next.init(options || defaultOptions, (err, t) => {
//make sure attributes is an array in case a string was provided
if (i18next.options.attributes instanceof String) {
@@ -21,6 +21,15 @@ describe('testing relative time support', () => {
}).then(() => done());
});
it('should provide a custom error message if lng option is not provided', () => {
expect(() => i18n.setup({
lng: undefined,
fallbackLng: 'en',
defaultNS: 'custom_default',
debug: false
})).toThrow();
});
it('should provide now unit', () => {
let expectedDate = new Date();

0 comments on commit 5deb4d2

Please sign in to comment.