vendredi 22 juillet 2016

How do I spy on private methods in a javascript module with sinon?

I am trying to unit test a module

var foobar = (function() {

  function privateBar() {
    privateBar();
  }

  function privateFoo() {
    privateBar();
  }

  function init()  {
    privateFoo();
  }

  return {
    init: init
  };
}());

How can I use sinon to spy on privateFoo and privateBar to make sure they are called?

Aucun commentaire:

Enregistrer un commentaire