I want to test a JavaScript method which sends POST message. I am using QUnit as my testing framework, but for some reason I am unable to send POST message when I call through QUnit. Here is the method to be tested:
function createObject(currentProject, name){
$.post(
"actionHandler.php",
{
"action": "createSomething",
"name": name
},
function(data) { //Receive data from backend
if (data.status == "ok") {
//do something
}
//do other things
},
"json"
);}
When I call this method from my QUnit test, I don't see any call being made to back end. How to send a POST message using QUnit? I want to receive some data as a JSON response and manipulate that data for other purpose, which seems interesting to test. Also my question is, is there other better ways to test such functions?
Aucun commentaire:
Enregistrer un commentaire