Never mind I worked it out for myself. I didn't need to refactor it either.
For anybody who might be interested to get write the test I had to add some dummy DIV elements to the test page, one to hold some test form data that would be used to send the email and test that the form hiding worked and one to hold the message result. Then I just called the submit function and tested to see if the form is hidden like its supposed to be and if the confirmation message appears. Its probably not the best way of doing it but it works, hopefully as I learn more about jQuery and QUnit I will be able to improve it. The code is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="js/jquery-1.4.2.js"></script>
<link rel="stylesheet" href="css/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/qunit.js"></script>
<script type="text/javascript" src="js/contact.js"></script>
<script>
$(document).ready(function(){
test('my test', function() {
$("#ajax-contact-form").submit();
stop();
setTimeout(function() {
equals($("#contactform").css("display"), "none", "Hide Contact Form");
ok($("#note div").hasClass("notification_ok") , "Message sent note");
start();
}, 500);
})
});
</script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="contactform">
<form id="ajax-contact-form" action="">
<input class="textbox" type="hidden" name="name" value="martin" />
<input class="textbox" type="hidden" name="email" value="validemail@email.com" />
<input class="textbox" type="hidden" name="subject" value="subject" />
<input class="textbox" type="hidden" name="message" value="this is a test message" />
</form>
test
</div>
<div id="note" style="display: none;"></div>
</body>
</html>