3
3
/* globals generateInputCompilerHelper: false */
4
4
5
5
describe ( 'input' , function ( ) {
6
- var helper = { } , $compile , $rootScope , $browser , $sniffer , $timeout , $q ;
6
+ var helper = { } , $compile , $rootScope , $browser , $sniffer ;
7
7
8
8
// UA sniffing to exclude Edge from some date input tests
9
9
var isEdge = / \b E d g e \/ / . test ( window . navigator . userAgent ) ;
10
10
11
11
generateInputCompilerHelper ( helper ) ;
12
12
13
- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$browser_ , _$sniffer_ , _$timeout_ , _$q_ ) {
13
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$browser_ , _$sniffer_ ) {
14
14
$compile = _$compile_ ;
15
15
$rootScope = _$rootScope_ ;
16
16
$browser = _$browser_ ;
17
17
$sniffer = _$sniffer_ ;
18
- $timeout = _$timeout_ ;
19
- $q = _$q_ ;
20
18
} ) ) ;
21
19
22
20
@@ -733,6 +731,8 @@ describe('input', function() {
733
731
} ) ;
734
732
735
733
734
+ // Support: Edge 16
735
+ // Edge does not support years with any number of digits other than 4.
736
736
if ( ! isEdge ) {
737
737
it ( 'should allow four or more digits in year' , function ( ) {
738
738
var inputElm = helper . compileInput ( '<input type="month" ng-model="value" ng-model-options="{timezone: \'UTC\'}"/>' ) ;
@@ -965,6 +965,8 @@ describe('input', function() {
965
965
expect ( inputElm ) . toBeValid ( ) ;
966
966
} ) ;
967
967
968
+ // Support: Edge 16
969
+ // Edge does not support years with any number of digits other than 4.
968
970
if ( ! isEdge ) {
969
971
it ( 'should allow four or more digits in year' , function ( ) {
970
972
var inputElm = helper . compileInput ( '<input type="week" ng-model="value" ng-model-options="{timezone: \'UTC\'}"/>' ) ;
@@ -1329,6 +1331,8 @@ describe('input', function() {
1329
1331
} ) ;
1330
1332
1331
1333
1334
+ // Support: Edge 16
1335
+ // Edge does not support years with any number of digits other than 4.
1332
1336
if ( ! isEdge ) {
1333
1337
it ( 'should allow four or more digits in year' , function ( ) {
1334
1338
var inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" />' ) ;
@@ -1535,6 +1539,24 @@ describe('input', function() {
1535
1539
1536
1540
expect ( inputElm ) . toBeValid ( ) ;
1537
1541
} ) ;
1542
+
1543
+
1544
+ // Support: Edge 16
1545
+ // Edge does not support years with any number of digits other than 4.
1546
+ if ( ! isEdge ) {
1547
+ it ( 'should correctly handle 2-digit years' , function ( ) {
1548
+ helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" />' ) ;
1549
+
1550
+ helper . changeInputValueTo ( '0001-01-01T12:34:00' ) ;
1551
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 1 ) ;
1552
+
1553
+ helper . changeInputValueTo ( '0099-01-01T12:34:00' ) ;
1554
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 99 ) ;
1555
+
1556
+ helper . changeInputValueTo ( '0100-01-01T12:34:00' ) ;
1557
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 100 ) ;
1558
+ } ) ;
1559
+ }
1538
1560
} ) ;
1539
1561
1540
1562
@@ -2305,9 +2327,9 @@ describe('input', function() {
2305
2327
2306
2328
it ( 'should allow Date objects as valid ng-max values' , function ( ) {
2307
2329
$rootScope . max = new Date ( 2012 , 1 , 1 , 1 , 2 , 0 ) ;
2308
- var inputElm = helper . compileInput ( '<input type="datetime-local " ng-model="value" name="alias" ng-max="max" />' ) ;
2330
+ var inputElm = helper . compileInput ( '<input type="date " ng-model="value" name="alias" ng-max="max" />' ) ;
2309
2331
2310
- helper . changeInputValueTo ( '2014-01-01T12:34:00 ' ) ;
2332
+ helper . changeInputValueTo ( '2014-01-01 ' ) ;
2311
2333
expect ( inputElm ) . toBeInvalid ( ) ;
2312
2334
2313
2335
$rootScope . max = new Date ( 2013 , 1 , 1 , 1 , 2 , 0 ) ;
@@ -2324,9 +2346,9 @@ describe('input', function() {
2324
2346
2325
2347
it ( 'should allow Date objects as valid ng-min values' , function ( ) {
2326
2348
$rootScope . min = new Date ( 2013 , 1 , 1 , 1 , 2 , 0 ) ;
2327
- var inputElm = helper . compileInput ( '<input type="datetime-local " ng-model="value" name="alias" ng-min="min" />' ) ;
2349
+ var inputElm = helper . compileInput ( '<input type="date " ng-model="value" name="alias" ng-min="min" />' ) ;
2328
2350
2329
- helper . changeInputValueTo ( '2010-01-01T12:34:00 ' ) ;
2351
+ helper . changeInputValueTo ( '2010-01-01 ' ) ;
2330
2352
expect ( inputElm ) . toBeInvalid ( ) ;
2331
2353
2332
2354
$rootScope . min = new Date ( 2014 , 1 , 1 , 1 , 2 , 0 ) ;
@@ -2340,6 +2362,24 @@ describe('input', function() {
2340
2362
expect ( inputElm ) . toBeValid ( ) ;
2341
2363
} ) ;
2342
2364
2365
+ // Support: Edge 16
2366
+ // Edge does not support years with any number of digits other than 4.
2367
+ if ( ! isEdge ) {
2368
+ it ( 'should correctly handle 2-digit years' , function ( ) {
2369
+ helper . compileInput ( '<input type="date" ng-model="value" name="alias" />' ) ;
2370
+
2371
+ helper . changeInputValueTo ( '0001-01-01' ) ;
2372
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 1 ) ;
2373
+
2374
+ helper . changeInputValueTo ( '0099-01-01' ) ;
2375
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 99 ) ;
2376
+
2377
+ helper . changeInputValueTo ( '0100-01-01' ) ;
2378
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 100 ) ;
2379
+ } ) ;
2380
+ }
2381
+
2382
+
2343
2383
describe ( 'ISO_DATE_REGEXP' , function ( ) {
2344
2384
var dates = [
2345
2385
// Validate date
0 commit comments