mirror of
https://github.com/status-im/react-native.git
synced 2025-01-11 01:56:26 +00:00
d363b1f2e2
Reviewed By: javache Differential Revision: D3229435 fb-gh-sync-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c fbshipit-source-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
25 lines
672 B
JavaScript
25 lines
672 B
JavaScript
// This mock only provides short-circuited methods of applyWithGuard and guard.
|
|
// A lot of modules rely on these two functions. This mock relieves their tests
|
|
// from depending on the real ErrorUtils module. If you need real error handling
|
|
// don't use this mock.
|
|
'use strict';
|
|
|
|
function execute(fun, context, args) {
|
|
return fun.apply(context, args);
|
|
}
|
|
|
|
function reportError(error) {
|
|
throw error;
|
|
}
|
|
|
|
var ErrorUtils = {
|
|
apply: jest.fn(execute),
|
|
applyWithGuard: jest.fn(execute),
|
|
guard: jest.fn(callback => callback),
|
|
inGuard: jest.fn().mockReturnValue(true),
|
|
reportError: jest.fn(reportError),
|
|
setGlobalHandler: jest.fn(),
|
|
};
|
|
|
|
module.exports = ErrorUtils;
|