I'm currently doing the chapter 13 of the book Test-Driven Development about doing javascript testing with QUnit. I'm trying to use version 2 of QUnit but my following test keep failing:
tests.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Javascript tests</title>
<link rel="stylesheet" href="qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<form>
<input name="text" id="id_text">
<div class="has-error">Error text</div>
</form>
</div>
<script src="http://ift.tt/wV40hO"></script>
<script src="qunit.js"></script>
<script src="../list.js"></script>
<script>
QUnit.test("errors should be hidden on keypress", function(assert) {
$('input[name="text"]').trigger('keypress');
assert.equal($('.has-error').is(':visible'), false);
});
QUnit.test("errors should not be hidden unles there is a keypress", function(assert){
assert.equal($('.has-error').is(':visible'), true);
});
</script>
</body>
</html>
list.html
jQuery(document).ready(function ($) {
$('input[name="text"]').on('keypress', function () {
$('.has-error').hide();
});
});
And here is the failing test that should be passing: Failing test
Thank you :)
Aucun commentaire:
Enregistrer un commentaire