@@ -2251,14 +2251,14 @@ describe('input', function() {
2251
2251
2252
2252
// INPUT TYPES
2253
2253
describe ( 'month' , function ( ) {
2254
- it ( 'should render blank if model is not a Date object' , function ( ) {
2254
+ it ( 'should throw if model is not a Date object' , function ( ) {
2255
2255
compileInput ( '<input type="month" ng-model="january"/>' ) ;
2256
2256
2257
- scope . $apply ( function ( ) {
2258
- scope . january = '2013-01' ;
2259
- } ) ;
2260
-
2261
- expect ( inputElm . val ( ) ) . toBe ( ' ') ;
2257
+ expect ( function ( ) {
2258
+ scope . $apply ( function ( ) {
2259
+ scope . january = '2013-01' ;
2260
+ } ) ;
2261
+ } ) . toThrowMinErr ( 'ngModel' , 'datefmt' , 'Expected `2013-01` to be a date ') ;
2262
2262
} ) ;
2263
2263
2264
2264
it ( 'should set the view if the model is a valid Date object' , function ( ) {
@@ -2433,14 +2433,14 @@ describe('input', function() {
2433
2433
} ) ;
2434
2434
2435
2435
describe ( 'week' , function ( ) {
2436
- it ( 'should set render blank if model is not a Date object' , function ( ) {
2436
+ it ( 'should throw if model is not a Date object' , function ( ) {
2437
2437
compileInput ( '<input type="week" ng-model="secondWeek"/>' ) ;
2438
2438
2439
- scope . $apply ( function ( ) {
2440
- scope . secondWeek = '2013-W02' ;
2441
- } ) ;
2442
-
2443
- expect ( inputElm . val ( ) ) . toBe ( ' ') ;
2439
+ expect ( function ( ) {
2440
+ scope . $apply ( function ( ) {
2441
+ scope . secondWeek = '2013-W02' ;
2442
+ } ) ;
2443
+ } ) . toThrowMinErr ( 'ngModel' , 'datefmt' , 'Expected `2013-W02` to be a date ') ;
2444
2444
} ) ;
2445
2445
2446
2446
it ( 'should set the view if the model is a valid Date object' , function ( ) {
@@ -2615,14 +2615,14 @@ describe('input', function() {
2615
2615
} ) ;
2616
2616
2617
2617
describe ( 'datetime-local' , function ( ) {
2618
- it ( 'should render blank if model is not a Date object' , function ( ) {
2618
+ it ( 'should throw if model is not a Date object' , function ( ) {
2619
2619
compileInput ( '<input type="datetime-local" ng-model="lunchtime"/>' ) ;
2620
2620
2621
- scope . $apply ( function ( ) {
2622
- scope . lunchtime = '2013-12-16T11:30:00' ;
2623
- } ) ;
2624
-
2625
- expect ( inputElm . val ( ) ) . toBe ( ' ') ;
2621
+ expect ( function ( ) {
2622
+ scope . $apply ( function ( ) {
2623
+ scope . lunchtime = '2013-12-16T11:30:00' ;
2624
+ } ) ;
2625
+ } ) . toThrowMinErr ( 'ngModel' , 'datefmt' , 'Expected `2013-12-16T11:30:00` to be a date ') ;
2626
2626
} ) ;
2627
2627
2628
2628
it ( 'should set the view if the model if a valid Date object.' , function ( ) {
@@ -2890,14 +2890,14 @@ describe('input', function() {
2890
2890
} ) ;
2891
2891
2892
2892
describe ( 'time' , function ( ) {
2893
- it ( 'should render blank if model is not a Date object' , function ( ) {
2893
+ it ( 'should throw if model is not a Date object' , function ( ) {
2894
2894
compileInput ( '<input type="time" ng-model="lunchtime"/>' ) ;
2895
2895
2896
- scope . $apply ( function ( ) {
2897
- scope . lunchtime = '11:30:00' ;
2898
- } ) ;
2899
-
2900
- expect ( inputElm . val ( ) ) . toBe ( ' ') ;
2896
+ expect ( function ( ) {
2897
+ scope . $apply ( function ( ) {
2898
+ scope . lunchtime = '11:30:00' ;
2899
+ } ) ;
2900
+ } ) . toThrowMinErr ( 'ngModel' , 'datefmt' , 'Expected `11:30:00` to be a date ') ;
2901
2901
} ) ;
2902
2902
2903
2903
it ( 'should set the view if the model if a valid Date object.' , function ( ) {
@@ -3141,11 +3141,24 @@ describe('input', function() {
3141
3141
} ) ;
3142
3142
3143
3143
describe ( 'date' , function ( ) {
3144
- it ( 'should render blank if model is not a Date object.' , function ( ) {
3144
+ it ( 'should throw if model is not a Date object.' , function ( ) {
3145
3145
compileInput ( '<input type="date" ng-model="birthday"/>' ) ;
3146
3146
3147
- scope . $apply ( function ( ) {
3148
- scope . birthday = '1977-10-22' ;
3147
+ expect ( function ( ) {
3148
+ scope . $apply ( function ( ) {
3149
+ scope . birthday = '1977-10-22' ;
3150
+ } ) ;
3151
+ } ) . toThrowMinErr ( 'ngModel' , 'datefmt' , 'Expected `1977-10-22` to be a date' ) ;
3152
+ } ) ;
3153
+
3154
+ it ( 'should set the view to empty when the model is an InvalidDate' , function ( ) {
3155
+ compileInput ( '<input type="date" ng-model="val"/>' ) ;
3156
+ // reset the element type to text otherwise newer browsers
3157
+ // would always set the input.value to empty for invalid dates...
3158
+ inputElm . attr ( 'type' , 'text' ) ;
3159
+
3160
+ scope . $apply ( function ( ) {
3161
+ scope . val = new Date ( 'a' ) ;
3149
3162
} ) ;
3150
3163
3151
3164
expect ( inputElm . val ( ) ) . toBe ( '' ) ;
0 commit comments