Created
September 29, 2016 18:18
-
-
Save francisbrito/ca05c99e484887c1543fb31d3ce0fd61 to your computer and use it in GitHub Desktop.
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
describe('My suite', () => { | |
it('works with promises', done => { | |
multiplyAsync(4, 5) | |
.then(r => expect(r).toBe(20)) | |
.then(done); | |
}); | |
it('works even if promises reject', done => { | |
divideAsync(2, 0) | |
.catch(e => expect(e.message).toBe('Attempted to divide by zero')) | |
.then(done); | |
}); | |
}); | |
function multiplyAsync(x, y) { | |
return Promise.resolve(x * y); | |
} | |
function divideAsync(x, y) { | |
if (y === 0) return Promise.reject(new Error('Attempted to divide by zero')); | |
return Promise.resolve(x / y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment