-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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.genMockFunction().mockImplementation(execute), | ||
applyWithGuard: jest.genMockFunction().mockImplementation(execute), | ||
inGuard: jest.genMockFunction().mockReturnValue(true), | ||
reportError: jest.genMockFunction().mockImplementation(reportError), | ||
setGlobalHandler: jest.genMockFunction(), | ||
}; | ||
|
||
module.exports = ErrorUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters