Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test(input): minlength test cases #5656

Closed
wants to merge 1 commit into from

Conversation

bwiklund
Copy link
Contributor

@bwiklund bwiklund commented Jan 7, 2014

Are these assertions correct? I'm adding new tests to minlength/maxlength, and the minlength one is failing. Should it be failing?

@@ -727,6 +727,9 @@ describe('input', function() {
it('should invalid shorter than given minlength', function() {
compileInput('<input type="text" ng-model="value" ng-minlength="3" />');

changeInputValueTo('');
expect(scope.value).toBeUndefined();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the failing assertion

@caitp
Copy link
Contributor

caitp commented Jan 7, 2014

HTML5 doesn't really have a proper minlength attribute, but emulating it with the pattern attribute, if an input isn't required, then the empty string appears to be perfectly valid in spite of not matching the pattern. http://jsfiddle.net/2g2ce/1/

Perhaps this is also appropriate for angular, but I'm not sure.

@bwiklund
Copy link
Contributor Author

bwiklund commented Jan 7, 2014

Is it correct to say that an empty string should always be valid, unless the input is has the required attribute?

It's a strange edge case, but I guess matching HTML5 makes the most sense.

@IgorMinar
Copy link
Contributor

@bwiklund I think that sounds right.

think about the end-user and developer experience: if an optional form field should contain at least 3 chars, then we can't make the field invalid if it's empty, because otherwise the user would always have to fill it with at least 3 chars and it would not be optional any more.

@IgorMinar
Copy link
Contributor

since this behavior is a bit surprising we should have an explicit it for it to make it clear that the behavior is desirable.

@gsklee
Copy link
Contributor

gsklee commented Jan 7, 2014

@caitp 👍 for the example!

@IgorMinar
Copy link
Contributor

@bwiklund btw when I asked you for a test in #5643 I meant a test that will check that we allow min and max length to be updated via databinding at runtime and the that the next time the input change we use the new min/max values are used for validation.

we need one spec (it) for maxlength and one for minlength.

@ghost ghost assigned IgorMinar Jan 7, 2014
@bwiklund
Copy link
Contributor Author

bwiklund commented Jan 7, 2014

Sounds good, I'll get that together tomorrow.

@bwiklund
Copy link
Contributor Author

bwiklund commented Jan 8, 2014

Is this the behavior we're trying to test for? Because databinding on minlength/maxlength doesn't seem supported at the moment.

bwiklund@28f3ca0

@tbosch tbosch modified the milestones: 1.2.12, 1.2.11, 1.2.13 Feb 3, 2014
@btford btford modified the milestones: 1.2.14, 1.2.13 Feb 15, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-beta.1, 1.2.14 Mar 1, 2014
@btford btford modified the milestones: 1.3.0-beta.2, 1.3.0-beta.1 Mar 10, 2014
@tbosch tbosch modified the milestones: 1.3.0-beta.3, 1.3.0-beta.2 Mar 14, 2014
@btford btford modified the milestones: 1.3.0-beta.4, 1.3.0-beta.3 Mar 24, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.0-beta.6, 1.3.0-beta.5 Apr 3, 2014
@IgorMinar IgorMinar added this to the 1.3.0-beta.7 milestone Apr 22, 2014
@IgorMinar IgorMinar removed this from the 1.3.0-beta.6 milestone Apr 22, 2014
@caitp caitp modified the milestones: 1.3.0-beta.9, 1.3.0-beta.8 May 9, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0, 1.3.0-beta.9 May 12, 2014
@Narretz
Copy link
Contributor

Narretz commented Jul 4, 2014

Both cases - valid when value becomes empty and dynamically evaluated attributes - are available since 1.3.0-beta.12 (valid when empty possibly earlier)

@Narretz Narretz closed this Jul 4, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants