Created
January 7, 2016 17:58
-
-
Save skratchdot/cc48e529029850873f87 to your computer and use it in GitHub Desktop.
An example of how I was using a sinon stub to mock creating uuids
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
import uuid from 'node-uuid'; | |
import sinon from 'sinon'; | |
const mockId = '00000000-0000-0000-0000-000000000000'; | |
describe('some test', () => { | |
it('does something', () => { | |
// create stub | |
sinon.stub(uuid, 'v4', function () { | |
return mockId; | |
}); | |
expect(someFunction()).to.contain(mockId); // call some function that uses uuid.v4() | |
uuid.v4.restore(); // this is important when using gulp.watch | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment