@@ -334,11 +334,10 @@ describe('datepicker directive', function () {
334
334
expect ( angular . isDate ( $rootScope . date ) ) . toBe ( true ) ;
335
335
} ) ;
336
336
337
- it ( 'to a date that is invalid, it gets invalid ' , function ( ) {
337
+ it ( 'to a date that is invalid, it doesn\`t update ' , function ( ) {
338
338
$rootScope . date = new Date ( 'pizza' ) ;
339
339
$rootScope . $digest ( ) ;
340
- expect ( element . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
341
- expect ( element . hasClass ( 'ng-invalid-date' ) ) . toBeTruthy ( ) ;
340
+ expect ( getTitle ( ) ) . toBe ( 'September 2010' ) ;
342
341
expect ( angular . isDate ( $rootScope . date ) ) . toBe ( true ) ;
343
342
expect ( isNaN ( $rootScope . date ) ) . toBe ( true ) ;
344
343
} ) ;
@@ -360,11 +359,10 @@ describe('datepicker directive', function () {
360
359
expect ( angular . isString ( $rootScope . date ) ) . toBe ( true ) ;
361
360
} ) ;
362
361
363
- it ( 'to a string that cannot be parsed by Date, it gets invalid ' , function ( ) {
362
+ it ( 'to a string that cannot be parsed by Date, it doesn\'t update ' , function ( ) {
364
363
$rootScope . date = 'pizza' ;
365
364
$rootScope . $digest ( ) ;
366
- expect ( element . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
367
- expect ( element . hasClass ( 'ng-invalid-date' ) ) . toBeTruthy ( ) ;
365
+ expect ( getTitle ( ) ) . toBe ( 'September 2010' ) ;
368
366
expect ( $rootScope . date ) . toBe ( 'pizza' ) ;
369
367
} ) ;
370
368
} ) ;
@@ -1876,27 +1874,41 @@ describe('datepicker directive', function () {
1876
1874
} ) ;
1877
1875
1878
1876
describe ( 'use with `ng-required` directive' , function ( ) {
1879
- beforeEach ( inject ( function ( ) {
1880
- $rootScope . date = '' ;
1881
- var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup ng-required="true"><div>' ) ( $rootScope ) ;
1882
- $rootScope . $digest ( ) ;
1883
- assignElements ( wrapElement ) ;
1884
- } ) ) ;
1877
+ describe ( '`ng-required is true`' , function ( ) {
1878
+ beforeEach ( inject ( function ( ) {
1879
+ $rootScope . date = '' ;
1880
+ var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup ng-required="true"><div>' ) ( $rootScope ) ;
1881
+ $rootScope . $digest ( ) ;
1882
+ assignElements ( wrapElement ) ;
1883
+ } ) ) ;
1885
1884
1886
- it ( 'should be invalid initially' , function ( ) {
1887
- expect ( inputEl . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
1888
- } ) ;
1885
+ it ( 'should be invalid initially and when no date ' , function ( ) {
1886
+ expect ( inputEl . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
1887
+ } ) ;
1889
1888
1890
- it ( 'should be valid if model has been specified' , function ( ) {
1891
- $rootScope . date = new Date ( ) ;
1892
- $rootScope . $digest ( ) ;
1893
- expect ( inputEl . hasClass ( 'ng-valid' ) ) . toBeTruthy ( ) ;
1889
+ it ( 'should be valid if model has been specified' , function ( ) {
1890
+ $rootScope . date = new Date ( ) ;
1891
+ $rootScope . $digest ( ) ;
1892
+ expect ( inputEl . hasClass ( 'ng-valid' ) ) . toBeTruthy ( ) ;
1893
+ } ) ;
1894
+
1895
+ it ( 'should be valid if model value is a valid timestamp' , function ( ) {
1896
+ $rootScope . date = Date . now ( ) ;
1897
+ $rootScope . $digest ( ) ;
1898
+ expect ( inputEl . hasClass ( 'ng-valid' ) ) . toBeTruthy ( ) ;
1899
+ } ) ;
1894
1900
} ) ;
1901
+ describe ( '`ng-required is false`' , function ( ) {
1902
+ beforeEach ( inject ( function ( ) {
1903
+ $rootScope . date = '' ;
1904
+ var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup ng-required="false"><div>' ) ( $rootScope ) ;
1905
+ $rootScope . $digest ( ) ;
1906
+ assignElements ( wrapElement ) ;
1907
+ } ) ) ;
1895
1908
1896
- it ( 'should be valid if model value is a valid timestamp' , function ( ) {
1897
- $rootScope . date = Date . now ( ) ;
1898
- $rootScope . $digest ( ) ;
1899
- expect ( inputEl . hasClass ( 'ng-valid' ) ) . toBeTruthy ( ) ;
1909
+ it ( 'should be valid initially and when no date' , function ( ) {
1910
+ expect ( inputEl . hasClass ( 'ng-valid' ) ) . toBeTruthy ( ) ;
1911
+ } ) ;
1900
1912
} ) ;
1901
1913
} ) ;
1902
1914
0 commit comments