Just mock all your dependencies of your function, so in your case this will be SockJS
and Stomp.over
.
var wsSpy = jasmine.createSpy();
spyOn(window, 'SockJs').andReturn(wsSpy);
var clientSpy = jasmine.createSpy();
spyOne(Stomp, 'over').andReturn(clientSpy)
After running your script you can test on the spies that they was called. To run the callback functions you can use mostRecentCall.args
to find them and call them in the test:
var successCallBack = clientSpy.mostRecentCall.args[2];
successCallBack();
var errorCallBack = clientSpy.mostRecentCall.args[3];
errorCallBack();