Skip to content

Instantly share code, notes, and snippets.

@johnbender
Created July 4, 2011 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbender/7431d5eb9226eda56168 to your computer and use it in GitHub Desktop.
Save johnbender/7431d5eb9226eda56168 to your computer and use it in GitHub Desktop.
manage state
(function(){
var foo = {
bar: function(){
// do something complex
},
baz: function(){
return bar + 3;
}
};
// capture the state of foo's members and make sure to reset that state after each test
manage(foo);
test( "baz adds 3 to the value of bar", function(){
// mock bar
foo.bar = function(){ return 5; };
same(foo.baz, 8);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment