lundi 4 septembre 2017

Please explain Sinon.spy unexpected behaviour

I have the following code:

    function f() {
        return "Hello, world!";
    }

    const bound = f.bind(null);

    const spyOriginal = sinon.spy(f);
    const spyBound = sinon.spy(bound);

    f();
    bound();

    window.console.log(spyOriginal.callCount, spyBound.callCount); // returns 0, 0

I've expected that console output will be 1, 1.

Can anyone explain how sinon.spy works? and how i should modify the code for checking call count of some function (when i have reference for it)?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire