Wrong type of error when testing javascript function -
i trying test following code:
/** abstract method placeholder */ myresult.prototype.get = thrownotimplementederror; function thrownotimplementederror(resultid) { throw new notimplementederror('please implement in item groups , items. call abstract'); }
with following test.
it('should have placeholder get', function(){ expect(function(){return myresult.get(123);}).tothrowerror(notimplementederror); });
what ends happenining typeerror thrown instead of custom notimplementederror. type error's message is: "myresult.get not function".
i'm wondering if might have calling variable in prototype 'get' think i've seen examples name javascript classes , use custom method call get. seems work other calls.
do have advice on why doesn't work call?
it's prototype function
so have test get
function instance of object this:
it('should have placeholder get', function(){ var resultobj = new myresult(); // create instance of object expect(function(){return resultobj.get(123);}).tothrowerror(notimplementederror); });
Comments
Post a Comment