Created
December 21, 2012 07:59
-
-
Save roycollings/4351331 to your computer and use it in GitHub Desktop.
AngularJS E2E / Javascript: easy way to test against a big list of possible inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Html | |
// | |
// NOTE: I am using different names for "id" and "ng-model" here so you can clearly see | |
// which one I need to use at different parts of the AngularJS E2E test. | |
// | |
<input type="text" id="dateField" ng-model="myDate"/> | |
// | |
// AngularJS E2E test. | |
// | |
var invalidDates = ["1/1234" , "123/1234", "1234/12", "12/1" , | |
"12/12" , "12/123" , "x2/1234", "1x/1234", | |
"12/x234", "12/1x34" , "12/12x4", "12/123x"]; | |
// ... etc ... | |
$.each(invalidDates, function(idx, invalidDate) { | |
it('does NOT allow invalid date: ' + invalidDate, function() { | |
input('myDate').enter(invalidDate); | |
expect(element('#dateField').val()).toMatch(invalidDate); // (assuming it validates in real-time) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment