Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created July 1, 2013 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrinaldi/5901296 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/5901296 to your computer and use it in GitHub Desktop.
Problem with async Jasmine tests.
define([
'service/auth'
], function(
auth
) {
describe('Tests "auth" service', function() {
var data;
var OPTIONS = {
CN: '147144147',
GV: '147153162'
};
auth.on.success.addOnce(function( response ) {
data = response;
});
auth.request(OPTIONS);
it('"status" should exist and be "true"', function() {
waitsFor(function() {
return data !== undefined;
});
runs(function() {
expect(data['status']).toBeDefined();
expect(data['status']).toBeTruthy();
});
});
});
});
define([
'service/login'
], function(
login
) {
describe('Tests "login" service', function() {
var data;
var OPTIONS = {
oper: 1,
codigoouemail: '101',
senha: '10151015'
};
login.on.success.addOnce(function( response ) {
data = response;
});
login.request(OPTIONS);
it('Should get the service response for user "' + OPTIONS.codigoouemail + '"', function() {
waitsFor(function() {
return data !== undefined;
});
runs(function() {
expect(data).toBeDefined();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment