Last active
October 17, 2016 16:33
-
-
Save quantizor/3b72f058215cda56b4055531e1f69c03 to your computer and use it in GitHub Desktop.
react-redux connect() mock for Jest
This file contains hidden or 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
/* | |
place this somewhere above where your test files are in a directory called __mocks__, e.g. | |
__mocks__/ | |
react-redux.js | |
src/ | |
myTestFile.spec.js | |
Requires an updated version of node with ES6 Proxy support. | |
*/ | |
const proxiedObject = new Proxy({}, { | |
get: function alwaysReturnSomething(target, name) { return name in target ? target[name] : proxiedObject; }, | |
}); | |
module.exports = { | |
connect: (cb = () => {}) => { | |
cb(proxiedObject); | |
return (x) => x; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment