How to stub class property

Viewed 5767

I am trying to Stub class property using sinon.

function wrapper() {
  this.obj = {"message":"hello"};
  this.sendmessege = function() {
    console.log(this.obj.message);
    return "message is:" + this.obj.message;
  } 
 }

// stub

var wrap = new wrapper();
stub = sinon.stub(wrap , 'sendmessege', function () { 
    return 'hola'; 
 });
 stub1 = sinon.stub(wrap , {'obj':
   {'message':'hii'}
 });

console.log(stub1);

its giving me

error : Attempted to wrap object property obj as function.

how i can stub obj ?

1 Answers
Related