I am trying to make a test of a function that does some pretty simple validation for a form.
However I cannot figure out how to use qunit without passing vars to the function.
here is an example of what I am talking about
function validateForm(){
var name = $('#name').val();
var submit = true;
//do some validation
//if submit true
form.submit();
}
all the example of qunit I see in the docs do something like this
ok(validateForm('hello'),'Hello is a valid name');
should I just modify my function or is there a way to work with such a setup.
//EDIT
The option I have chosen to pursue right now is setting up another function above the current one that simply parses the form inputs and then sends them as vars to the validateForm() function
What I ended up doing was modifying the function in a way that allowed me to pass the vars in the test.
before the code would do something like this
Now When the submit button is pressed it goes to another function that parses the args out for me also added a ‘test’ arg so the form is not being submitted during the tests.
Then my qunit looks something like this