Created
February 14, 2017 16:17
-
-
Save sam-artuso/281e4273cf582f764ebd156f194dc559 to your computer and use it in GitHub Desktop.
How to unit test a promise deliberately designed to side-effect?
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
// demo.js | |
function f() { | |
return Promise.resolve(true) | |
} | |
function g() { | |
Promise.resolve(true) | |
} | |
module.exports = { f, g } | |
// demo.test.js | |
const demo = require('./demo') | |
describe('f()', () => { | |
it('should resolve to true', () => { | |
return demo.f().then(result => { | |
expect(result).toBe(true) | |
}) | |
}) | |
}) | |
describe('g()', () => { | |
it.skip('should resolve to true', () => { | |
// ??? | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment