So, I got this code:
function initial(a,b,c){
if ( isNaN(a) || isNaN(b) || isNaN(c) ){
//do something
}
else {
//do something
}
}
I need to expect an TypeError when a string is used instead of a number. Initially I thought that declaring expectations for a, b and c separately would be ok, like this:
expect(a).to.be.a('number');
expect(b).to.be.a('number');
expect(c).to.be.a('number');
I want it to actually observe the function and expect certain parameters to throw an error, something like:
expect( initial('foo','foo','foo') ).to.Throw(TypeError);
But this is not working, and I've tested quite some options and none seem to actual give me the TypeError I want. Does any body know the right way to expect certain function parameters?
Thank you!
Aucun commentaire:
Enregistrer un commentaire