Last active
December 12, 2015 05:28
-
-
Save joeriks/4721601 to your computer and use it in GitHub Desktop.
Async testing with WebStorm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AsyncTestCase("Some tests", {"test successfull auth ": function(queue) { | |
var success = false; | |
var errormessage=""; | |
queue.call("try authorize",function(callbacks) { | |
var successcallback = function(data){ | |
success=true; | |
callback(); | |
}; | |
var errorcallback = function(data){ | |
// make readable string with error message | |
errormessage = JSON.stringify(data); | |
callback(); | |
}; | |
var callback = callbacks.add(function(data){ | |
// empty function just to make async test stop and continue | |
// if we only had one callback this could be the actual callback function | |
}); | |
server.authorize("somevaliduser", "somevalidpassword", successcallback, errorcallback); | |
}); | |
queue.call("verify", function(){ | |
assertEquals("", errormessage); | |
assertEquals(true,success); | |
}); | |
}}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../../fw/server.ts" /> | |
/// <reference path="../refs.ts" /> | |
declare var AsyncTestCase; | |
declare var assertEquals; | |
AsyncTestCase("Some new tests", {"test successfull auth ": function(queue) { | |
var success = false; | |
var errormessage=""; | |
queue.call("try authorize",function(callbacks) { | |
var successcallback = function(data){ | |
success=true; | |
callback(); | |
}; | |
var errorcallback = function(data){ | |
errormessage = JSON.stringify(data); | |
callback(); | |
}; | |
var callback = callbacks.add(function(data){ | |
}); | |
server.authorize("somevaliduser", "somevalidpassword", successcallback, errorcallback); | |
}); | |
queue.call("verify", function(){ | |
assertEquals("", errormessage); | |
assertEquals(true,success); | |
}); | |
}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment