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
@@ -763,6 +761,8 @@ describe('input', function() {
763
761
} ) ;
764
762
765
763
764
+ // Support: Edge 16
765
+ // Edge does not support years with any number of digits other than 4.
766
766
if ( ! isEdge ) {
767
767
it ( 'should allow four or more digits in year' , function ( ) {
768
768
var inputElm = helper . compileInput ( '<input type="month" ng-model="value" ng-model-options="{timezone: \'UTC\'}"/>' ) ;
@@ -992,6 +992,8 @@ describe('input', function() {
992
992
expect ( inputElm ) . toBeValid ( ) ;
993
993
} ) ;
994
994
995
+ // Support: Edge 16
996
+ // Edge does not support years with any number of digits other than 4.
995
997
if ( ! isEdge ) {
996
998
it ( 'should allow four or more digits in year' , function ( ) {
997
999
var inputElm = helper . compileInput ( '<input type="week" ng-model="value" ng-model-options="{timezone: \'UTC\'}"/>' ) ;
@@ -1353,6 +1355,8 @@ describe('input', function() {
1353
1355
} ) ;
1354
1356
1355
1357
1358
+ // Support: Edge 16
1359
+ // Edge does not support years with any number of digits other than 4.
1356
1360
if ( ! isEdge ) {
1357
1361
it ( 'should allow four or more digits in year' , function ( ) {
1358
1362
var inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" />' ) ;
@@ -1556,6 +1560,24 @@ describe('input', function() {
1556
1560
1557
1561
expect ( inputElm ) . toBeValid ( ) ;
1558
1562
} ) ;
1563
+
1564
+
1565
+ // Support: Edge 16
1566
+ // Edge does not support years with any number of digits other than 4.
1567
+ if ( ! isEdge ) {
1568
+ it ( 'should correctly handle 2-digit years' , function ( ) {
1569
+ helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" />' ) ;
1570
+
1571
+ helper . changeInputValueTo ( '0001-01-01T12:34:00' ) ;
1572
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 1 ) ;
1573
+
1574
+ helper . changeInputValueTo ( '0099-01-01T12:34:00' ) ;
1575
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 99 ) ;
1576
+
1577
+ helper . changeInputValueTo ( '0100-01-01T12:34:00' ) ;
1578
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 100 ) ;
1579
+ } ) ;
1580
+ }
1559
1581
} ) ;
1560
1582
1561
1583
@@ -2323,9 +2345,9 @@ describe('input', function() {
2323
2345
2324
2346
it ( 'should allow Date objects as valid ng-max values' , function ( ) {
2325
2347
$rootScope . max = new Date ( 2012 , 1 , 1 , 1 , 2 , 0 ) ;
2326
- var inputElm = helper . compileInput ( '<input type="datetime-local " ng-model="value" name="alias" ng-max="max" />' ) ;
2348
+ var inputElm = helper . compileInput ( '<input type="date " ng-model="value" name="alias" ng-max="max" />' ) ;
2327
2349
2328
- helper . changeInputValueTo ( '2014-01-01T12:34:00 ' ) ;
2350
+ helper . changeInputValueTo ( '2014-01-01 ' ) ;
2329
2351
expect ( inputElm ) . toBeInvalid ( ) ;
2330
2352
2331
2353
$rootScope . max = new Date ( 2013 , 1 , 1 , 1 , 2 , 0 ) ;
@@ -2342,9 +2364,9 @@ describe('input', function() {
2342
2364
2343
2365
it ( 'should allow Date objects as valid ng-min values' , function ( ) {
2344
2366
$rootScope . min = new Date ( 2013 , 1 , 1 , 1 , 2 , 0 ) ;
2345
- var inputElm = helper . compileInput ( '<input type="datetime-local " ng-model="value" name="alias" ng-min="min" />' ) ;
2367
+ var inputElm = helper . compileInput ( '<input type="date " ng-model="value" name="alias" ng-min="min" />' ) ;
2346
2368
2347
- helper . changeInputValueTo ( '2010-01-01T12:34:00 ' ) ;
2369
+ helper . changeInputValueTo ( '2010-01-01 ' ) ;
2348
2370
expect ( inputElm ) . toBeInvalid ( ) ;
2349
2371
2350
2372
$rootScope . min = new Date ( 2014 , 1 , 1 , 1 , 2 , 0 ) ;
@@ -2358,6 +2380,24 @@ describe('input', function() {
2358
2380
expect ( inputElm ) . toBeValid ( ) ;
2359
2381
} ) ;
2360
2382
2383
+ // Support: Edge 16
2384
+ // Edge does not support years with any number of digits other than 4.
2385
+ if ( ! isEdge ) {
2386
+ it ( 'should correctly handle 2-digit years' , function ( ) {
2387
+ helper . compileInput ( '<input type="date" ng-model="value" name="alias" />' ) ;
2388
+
2389
+ helper . changeInputValueTo ( '0001-01-01' ) ;
2390
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 1 ) ;
2391
+
2392
+ helper . changeInputValueTo ( '0099-01-01' ) ;
2393
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 99 ) ;
2394
+
2395
+ helper . changeInputValueTo ( '0100-01-01' ) ;
2396
+ expect ( $rootScope . value . getFullYear ( ) ) . toBe ( 100 ) ;
2397
+ } ) ;
2398
+ }
2399
+
2400
+
2361
2401
describe ( 'ISO_DATE_REGEXP' , function ( ) {
2362
2402
var dates = [
2363
2403
// Validate date
0 commit comments