mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 07:16:36 +01:00
50d8740a0d
Some TypeScript files in shared/modules are not being linted. Add them to the ESLint config and fix any lint violations that arise from doing so.
33 lines
993 B
TypeScript
33 lines
993 B
TypeScript
import log from 'loglevel';
|
|
import { isErrorWithMessage, logErrorWithMessage } from './error';
|
|
|
|
jest.mock('loglevel');
|
|
|
|
describe('error module', () => {
|
|
afterEach(() => {
|
|
jest.resetAllMocks();
|
|
});
|
|
|
|
describe('isErrorWithMessage', () => {
|
|
it('returns true when passed an instance of an Error', () => {
|
|
expect(isErrorWithMessage(new Error('test'))).toBe(true);
|
|
});
|
|
|
|
it('returns false when passed a string', () => {
|
|
expect(isErrorWithMessage('test')).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('logErrorWithMessage', () => {
|
|
it('calls loglevel.error with the error.message when passed an instance of Error', () => {
|
|
logErrorWithMessage(new Error('test'));
|
|
expect(log.error).toHaveBeenCalledWith('test');
|
|
});
|
|
|
|
it('calls loglevel.error with the parameter passed in when parameter is not an instance of Error', () => {
|
|
logErrorWithMessage({ test: 'test' });
|
|
expect(log.error).toHaveBeenCalledWith({ test: 'test' });
|
|
});
|
|
});
|
|
});
|