mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 18:10:43 +01:00
refactor: 💡 warn on deprecated usage instead of error-ing
This commit is contained in:
parent
5a215b22ce
commit
3add4e66b7
@ -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.`,
|
||||
);
|
||||
|
||||
|
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user