I'm using MeteorJS with angular and want to test controller. My controller use $reactive(this).attach($scope). I need to check, if this method was called.
I create something like that for spy:
var $reactive = function(ctrl) {
return {
attach:function(scope) {}
}
};
So I can call it like that:
$reactive('aaa').attach('bbb');
How I can do it in tests?
spyOn($reactive, 'attach');
Doesn't work. I got Error: attach() method does not exist
And how to check if it was called? This is good call?
expect($reactive).toHaveBeenCalledWith(controller);
And how to check that function attach was called with args (scope)?
$reactive
returns an object that contains the attach method, right? And you want to test thisattach
method to have been called. – Facility