Sometimes, I write functions that, under certain circumstances, should do nothing. Not only is it acceptable that they don't do anything, but it is actually the required behavior. Is there a pattern to test a function to make sure it has no side effects?
As an example, I'm currently testing a function that looks like this:
function onRowOfIconsClicked(iconName) {
if (iconName === 'new') {
doSomeAwesomeStuffImAlreadyTesting();
}
// We haven't implemented the other icons yet, so for now,
// do nothing and don't throw an error if a different icon
// is clicked
}
How would I write a test case to assert the current requirement that when onRowOfIconsClicked
is called with an iconName
other than "new"
, the function does nothing?
Aucun commentaire:
Enregistrer un commentaire