mardi 5 juillet 2016

How to fake signalR connection for unit test

We have a webservice which provides real time data for our application. In order to connect to that webservice we use $.connection. Code for that will be like -

this.myConnect = $.connection(myURL);
this.myConnect.start(settingsWhichIncludesACallBack).fail(anotherfunction);

How can I spy on the start and connection method. In other words, I don't want to establish an actual connection to the webService but still would like that my callback (passed as settings) to be call.

I am trying to use Jasmine spies to call fake for $.connection but for obvious reasons it fails on this.myConnect.start as 'not a function' for type error.

Aucun commentaire:

Enregistrer un commentaire