javascript - Expect.js validation issue on Codeacademy Lesson -
i creating lesson on codeacademy enables users learn creation of html forms. own entertainment, we're on same page. after reading submission test guidelines , api decided use expect.js
handle bulk of validation since need traverse dom.
so lesson creating asks users create two label elements (with content inside label tags) , two input fields (with type
attribute defined , value set text
). again, criteria follows:
- create 2
<label>
elements inside<form>
element. sure indicate user filling out! - create 2
<input>
elements below each of<label>
elements. sure include , definetype
attribute!
let's assume have following code:
<!doctype html> <html> <head> <title></title> </head> <body> <form> <label>foo</label> <input type="text"> <label>bar</label> <!-- should below here here --> <input> </form> </body> </html>
this pass. understanding of how expect.js operates , current validation, should not pass because user neglected add second type="text"
attribute
my validation criteria follows:
// items exist? $expect('form > label').to.have.items(2, 'did forget create 2 <label></label> tags?').and.to.have.text(/[a-za-z0-9]{1,}/i, 'do label tags have information inside of them? <label>my label</label>'); $expect('form > input').to.have.items(2, 'did forget create 2 <input> tags?').and.to.have.attr('type', 'text'); // input fields exist below labels? $expect('label').to.have.siblings('input', "are input fields below labels?");
if user submits html code should fail, passing. disconnect when user enters second set of <label>
, <input>
tags. if omit content within second <label>
and/or type
attribute value of text
still pass.
is there special or unique missing here? have tried validation code supplied above , without out method chaining no avail.
what have tried
- looked on codeacademy hints on how rectify issue
- looked on expect.js readme hints
- looking on stackoverflow hints
- removed method chaining , reestablished method chaining
i think need that/which
feature, terribly documented.
$expect('form > input').to.have.items(2, 'did forget create 2 <input> tags?').that.has.attr('type', 'text');
Comments
Post a Comment