Hello,
Firstly I am sorry for my english.
I am trying to use unit test with Jasmine and i have a problem with a
asynchronous function.
The function have three arguments, one for success callback, one for fail
callback and other for notification callback. So I register this callbacks
on spyOn().
describe("Estado de '$scope.connected' - ", function() {
beforeEach(inject(function() {
handlers = {
success : function(event) {
console.log(event);
},
error : function(event) {
console.log(event);
},
lostConnection : function(event) {
console.log(event);
},
};
spyOn(handlers, 'success').and.callThrough();
spyOn(handlers, 'error').and.callThrough();
spyOn(handlers, 'lostConnection').and.callThrough();
When I call the function manager.connect() passing callback functions,
manager.connect() return async result. But my problem this callbacks never
called in unit test.
it("quando connectado ao websocket '$scope.connected' deverá ser `true`",
function() {
var config = {
uri : '1000@'+test_server,
};
_ws = new ws(test_server, 5515, true);
_agent = new agent(config);
_manager = new manager(_ws, _agent);
_manager.connect( handlers.success, handlers.error, handlers.lostConnection
);
expect(handlers.success).toHaveBeenCalled();
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.