-
-
Save johnbender/7431d5eb9226eda56168 to your computer and use it in GitHub Desktop.
manage state
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
(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