refactor: 💡 warn on deprecated usage instead of error-ing

This commit is contained in:
Christian Kaisermann 2020-11-24 10:48:44 -03:00
parent d3267d9913
commit f2cea89535
2 changed files with 5 additions and 5 deletions

View File

@ -56,7 +56,7 @@ const formatMessage: MessageFormatter = (id, options = {}) => {
message = defaultValue || id;
} else if (typeof message !== 'string') {
console.error(
console.warn(
`[svelte-i18n] Message with id "${id}" must be of type "string", found: "${typeof message}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`,
);

View File

@ -106,16 +106,16 @@ describe('format message', () => {
});
it('errors out when value found is not string', () => {
const { error } = global.console;
const { warn } = global.console;
jest.spyOn(global.console, 'error').mockImplementation();
jest.spyOn(global.console, 'warn').mockImplementation();
expect(typeof formatMessage('form')).toBe('object');
expect(console.error).toBeCalledWith(
expect(console.warn).toBeCalledWith(
`[svelte-i18n] Message with id "form" must be of type "string", found: "object". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`,
);
global.console.error = error;
global.console.warn = warn;
});
it('warn on missing messages', () => {