Search code examples
javascriptsinonmeld

Is there way to test below code using sinon


meld.before(myObject, 'doSomething', function(x) {
    console.log(2);
});

did any one tried writing test case for above code statement.

Using meld.js library and sinon


Solution

  • Solution: It is just about calling this method

    call (myObject.doSomething)  it logs 2 and your log
    

    remove behavior

    var rem = meld.before(myObject, 'doSomething', function(x) {
        console.log(2);
    }); 
    
    rem.remove();
    
    now call again (myObject.doSomething)  // just logs normal log