From f2cea89535cb9a97ad177813810524b2d25cb61e Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Tue, 24 Nov 2020 10:48:44 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20warn=20on=20deprecat?= =?UTF-8?q?ed=20usage=20instead=20of=20error-ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/runtime/stores/formatters.ts | 2 +- test/runtime/stores/formatters.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/runtime/stores/formatters.ts b/src/runtime/stores/formatters.ts index 328d3c3..8edb957 100644 --- a/src/runtime/stores/formatters.ts +++ b/src/runtime/stores/formatters.ts @@ -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.`, ); diff --git a/test/runtime/stores/formatters.test.ts b/test/runtime/stores/formatters.test.ts index 3462407..1c8f36d 100644 --- a/test/runtime/stores/formatters.test.ts +++ b/test/runtime/stores/formatters.test.ts @@ -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', () => {