-
-
Save robertklep/595aa56e39c091f87412a41cab5cc866 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
const assert = require('assert'); | |
function increment(value) { | |
return new Promise((resolve, reject) => { | |
if (value < 0) { | |
reject(Error('I can only increment positive numbers')); | |
} else { | |
resolve(value + 1); | |
} | |
}); | |
} | |
describe('increment', () => { | |
it('should increment the value by 1', () => { | |
return increment(123).then(value => { | |
assert.equal(value, 124); | |
}); | |
}); | |
it('should fail when incrementing negative numbers', () => { | |
return increment(-123).then(value => { | |
throw Error('it should have failed'); | |
}, err => { | |
// swallow the error | |
}); | |
}); | |
// this test will intentionally fail | |
it('should not increment the value by 2', () => { | |
return increment(123).then(value => { | |
assert.equal(value, 125); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment