Created
May 9, 2016 19:54
-
-
Save benwillkommen/92ce116b96801c95af070199ba8ab4ad to your computer and use it in GitHub Desktop.
mocking w/ sinon example
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
//weird codewars function | |
function _if(bool, func1, func2) { | |
if(bool === true){ | |
return func1(); | |
} else { | |
return func2(); | |
} | |
}; | |
//arrange | |
var function1 = function(){console.log("asdf")}; | |
var function2 = function(){console.log("jkl;")}; | |
var spy1 = sinon.spy(function1); | |
var spy2 = sinon.spy(function2); | |
//act | |
_if(true, function1, function2); | |
//assert | |
Test.assertTrue(spy1.calledOnce); | |
Test.assertFalse(spy2.called); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment