Skip to content

Commit

Permalink
test: updating unit test to cover undefined case (aws-amplify#1392)
Browse files Browse the repository at this point in the history
  • Loading branch information
zchenwei authored Feb 23, 2022
1 parent b390fdc commit 1f5e696
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/react/src/hooks/__tests__/useDeprecationWarning.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

0 comments on commit 1f5e696

Please sign in to comment.