From 1f5e69666a6865cb400d7e8dcadf39ed393e54cb Mon Sep 17 00:00:00 2001 From: Chenwei Zhang <40295569+zchenwei@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:29:21 -0800 Subject: [PATCH] test: updating unit test to cover undefined case (#1392) --- .../hooks/__tests__/useDeprecationWarning.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react/src/hooks/__tests__/useDeprecationWarning.test.tsx b/packages/react/src/hooks/__tests__/useDeprecationWarning.test.tsx index 25a25e36bd9..af5c5b39a5c 100644 --- a/packages/react/src/hooks/__tests__/useDeprecationWarning.test.tsx +++ b/packages/react/src/hooks/__tests__/useDeprecationWarning.test.tsx @@ -29,4 +29,17 @@ describe('useDeprecationWarning', () => { expect(console.warn).toHaveBeenCalledTimes(0); expect(console.warn).not.toHaveBeenCalledWith(message); }); + + it('should not throw reference error if process is not defined', async () => { + const message = 'This component is deprecated, use X instead'; + + const originalProcess = global.process; + delete global.process; + + renderHook(() => useDeprecationWarning({ message })); + expect(console.warn).toHaveBeenCalledTimes(1); + expect(console.warn).toHaveBeenCalledWith(message); + + global.process = originalProcess; + }); });