@@ -334,11 +334,10 @@ describe('datepicker directive', function () {
334334 expect ( angular . isDate ( $rootScope . date ) ) . toBe ( true ) ;
335335 } ) ;
336336
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 ( ) {
338338 $rootScope . date = new Date ( 'pizza' ) ;
339339 $rootScope . $digest ( ) ;
340- expect ( element . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
341- expect ( element . hasClass ( 'ng-invalid-date' ) ) . toBeTruthy ( ) ;
340+ expect ( getTitle ( ) ) . toBe ( 'September 2010' ) ;
342341 expect ( angular . isDate ( $rootScope . date ) ) . toBe ( true ) ;
343342 expect ( isNaN ( $rootScope . date ) ) . toBe ( true ) ;
344343 } ) ;
@@ -360,11 +359,10 @@ describe('datepicker directive', function () {
360359 expect ( angular . isString ( $rootScope . date ) ) . toBe ( true ) ;
361360 } ) ;
362361
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 ( ) {
364363 $rootScope . date = 'pizza' ;
365364 $rootScope . $digest ( ) ;
366- expect ( element . hasClass ( 'ng-invalid' ) ) . toBeTruthy ( ) ;
367- expect ( element . hasClass ( 'ng-invalid-date' ) ) . toBeTruthy ( ) ;
365+ expect ( getTitle ( ) ) . toBe ( 'September 2010' ) ;
368366 expect ( $rootScope . date ) . toBe ( 'pizza' ) ;
369367 } ) ;
370368 } ) ;
@@ -1876,27 +1874,41 @@ describe('datepicker directive', function () {
18761874 } ) ;
18771875
18781876 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+ } ) ) ;
18851884
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+ } ) ;
18891888
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+ } ) ;
18941900 } ) ;
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+ } ) ) ;
18951908
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+ } ) ;
19001912 } ) ;
19011913 } ) ;
19021914
0 commit comments