@@ -59,7 +59,6 @@ describe('Directives: validation - match', function() {
5959 expect ( compiled . hasClass ( 'ng-valid' ) ) . to . be . true ( ) ;
6060 } ) ;
6161
62-
6362 it ( 'returns false if $modelValue are not identical' , function ( ) {
6463 $scope . confirmation = false ;
6564 $scope . original = undefined ;
@@ -108,6 +107,80 @@ describe('Directives: validation - match', function() {
108107 $scope . $digest ( ) ;
109108 expect ( form . testConfirm . $modelValue ) . to . be . undefined ( ) ;
110109 } ) ;
111-
110+
111+ } ) ;
112+
113+ describe ( 'caseless validation' , function ( ) {
114+
115+ describe ( 'behavior:' , function ( ) {
116+ var validTemplate = '<input ng-model="confirmation" match="original" match-caseless="true"></input>' ;
117+
118+ it ( 'returns true if no model value has been defined' , function ( ) {
119+ compiled = $compile ( validTemplate ) ( $scope ) ;
120+ expect ( $scope . confirmation ) . to . be . undefined ( ) ;
121+ $scope . $digest ( ) ;
122+ expect ( compiled . hasClass ( 'ng-valid' ) ) . to . be . true ( ) ;
123+ } ) ;
124+
125+
126+ it ( 'returns true if $modelValue are identical' , function ( ) {
127+ $scope . confirmation = "value" ;
128+ compiled = $compile ( validTemplate ) ( $scope ) ;
129+ $scope . original = "value" ;
130+ $scope . $digest ( ) ;
131+ expect ( compiled . hasClass ( 'ng-valid' ) ) . to . be . true ( ) ;
132+ } ) ;
133+
134+ it ( 'returns true if $modelValue are not identical but match caselessly' , function ( ) {
135+ $scope . confirmation = "VALUE" ;
136+ compiled = $compile ( validTemplate ) ( $scope ) ;
137+ $scope . original = "value" ;
138+ $scope . $digest ( ) ;
139+ expect ( compiled . hasClass ( 'ng-valid' ) ) . to . be . true ( ) ;
140+ } ) ;
141+
142+ it ( 'returns false if $modelValue are not identical' , function ( ) {
143+ $scope . confirmation = false ;
144+ $scope . original = undefined ;
145+ compiled = $compile ( validTemplate ) ( $scope ) ;
146+ $scope . $digest ( ) ;
147+ expect ( compiled . hasClass ( 'ng-valid' ) ) . to . be . false ( ) ;
148+ } ) ;
149+
150+ } ) ;
151+
152+
153+ describe ( 'Form level validation' , function ( ) {
154+ var form ,
155+ element ,
156+ inputValue = 'testValue' ;
157+
158+ beforeEach ( function ( ) {
159+ element = angular . element (
160+ '<form name="form">' +
161+ '<input type="text" ng-model="test" name="test"></input>' +
162+ '<input type="text" match="form.test" match-caseless="true" ng-model="testConfirm" name="testConfirm"></input>' +
163+ '</form>'
164+ ) ;
165+ $scope . test = inputValue ;
166+ $compile ( element ) ( $scope ) ;
167+ $scope . $digest ( ) ;
168+ form = $scope . form ;
169+ } ) ;
170+
171+ it ( 'should check if $viewValues are identical' , function ( ) {
172+ form . testConfirm . $setViewValue ( inputValue ) ;
173+ $scope . $digest ( ) ;
174+ expect ( form . testConfirm . $error . match ) . to . be . undefined ( ) ;
175+ } ) ;
176+
177+ it ( 'should check if $viewValues are not identical but match caselessly' , function ( ) {
178+ form . testConfirm . $setViewValue ( inputValue . toUpperCase ( ) ) ;
179+ $scope . $digest ( ) ;
180+ expect ( form . testConfirm . $error . match ) . to . be . undefined ( ) ;
181+ } ) ;
182+
183+ } ) ;
184+
112185 } ) ;
113186} ) ;
0 commit comments