Closed Cooya closed 5 years ago
Hey, I am looking for a way to accomplish this with simple-mock :
const obj = { fct: str => console.log(str) }; obj.fct('hello'); // display "hello" obj.fct2 = obj.fct; obj.fct = obj.fct2.bind(obj, 'hi'); obj.fct('hello'); // display "hi"
I just want to make a mock to replace only the parameters but keep the call to the original function.
This should do it:
const simple = require('simple-mock') simple.mock(obj, 'fct', obj.fct.bind(obj, 'hi')) obj.fct('hello') // display "hi"
Hey, I am looking for a way to accomplish this with simple-mock :
I just want to make a mock to replace only the parameters but keep the call to the original function.