mercredi 18 mai 2016

How to spy on function calling other function in Jasmine?

I have the problem:

var async = require('async');

function a() {
  async.series([b,c], function(err) {
    console.log('Done');
  });
};
function b(next) {
  next();
};
function c(next) {
  next();
};

var methods = {
  a: a,
  b: b,
  c: c
};

And I am trying to write a test like so:

spyOn(methods.a);
methods.a();
expect(methods.b).toHaveBeenCalled();
expect(methods.c).toHaveBeenCalled();

However both b and c do not register as having been called. Any ideas how to properly test this behavior?

Aucun commentaire:

Enregistrer un commentaire