Created
October 30, 2019 05:44
-
-
Save gbalbuena/799de71c9ba50a21eb9e602866e9da54 to your computer and use it in GitHub Desktop.
jest mock library for async-redis deps, it has to be in __mock__ dir
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
| let mock = { mock: true }; | |
| const client = { | |
| set: function() { | |
| }, | |
| get: function() { | |
| return JSON.stringify(mock) | |
| }, | |
| quit: function() { | |
| } | |
| } | |
| function setExpectation(_mock) { | |
| mock = _mock; | |
| } | |
| function createClient() { | |
| return client; | |
| } | |
| module.exports = { | |
| createClient, | |
| setExpectation | |
| } |
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
| const asyncRedis = require('async-redis'); | |
| describe('something', () => { | |
| it('test', async () => { | |
| asyncRedis.setExpectation({ success: true }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment