jQuery validator not working in unit testing
- by Dbugger
I have this small HTML file:
<html>
    <head></head>
    <body>
        <form id='MyForm'>
            <input type='text' required />
            <input type='submit' />
        </form>
        <script src="/js/jquery-1.9.0.js"></script>
        <script src="/js/jquery.validate.js"></script>
        <script>
            var validator = $("#MyForm").validate();
            alert(validator.form());
        </script>
    </body>
</html>
This alerts me with "false", which is the expected behaviour.
The problem comes when I go to unit testing, with js-test-driver:
TestCase("MyTests", {
    setUp: function() {
        this.myform = "<form id='MyForm'><input type='text' required /><input type='submit'  /></form>";
        this.validator = $(this.myform).validate();
        jstestdriver.console.log("Does the form validate? " + this.validator.form());
    },
    test_empty: function() {
    },
});
This code returns me the string
Does the form validate? true
This is a simplified version of my project of course, but the point is that I dont seem to be able to unit test the validation module im developing, since the jQuery validate plugin doesnt seem to work. What am I missing?