1
+
2
+
1
3
describe ( 'timepicker directive' , function ( ) {
2
4
var $rootScope , element ;
3
5
@@ -37,15 +39,15 @@ describe('timepicker directive', function () {
37
39
}
38
40
39
41
function getArrow ( isUp , tdIndex ) {
40
- return element . find ( 'tr ') . eq ( ( isUp ) ? 0 : 2 ) . find ( 'td ' ) . eq ( tdIndex ) . find ( 'a' ) . eq ( 0 ) ;
42
+ return element . children ( 'div ') . eq ( ( isUp ) ? 0 : 2 ) . find ( 'div ' ) . eq ( tdIndex ) . find ( 'a' ) . eq ( 0 ) ;
41
43
}
42
44
43
45
function getHoursButton ( isUp ) {
44
46
return getArrow ( isUp , 0 ) ;
45
47
}
46
48
47
49
function getMinutesButton ( isUp ) {
48
- return getArrow ( isUp , 2 ) ;
50
+ return getArrow ( isUp , 1 ) ;
49
51
}
50
52
51
53
function getMeridianButton ( ) {
@@ -71,8 +73,7 @@ describe('timepicker directive', function () {
71
73
return e ;
72
74
}
73
75
74
- it ( 'contains three row & three input elements' , function ( ) {
75
- expect ( element . find ( 'tr' ) . length ) . toBe ( 3 ) ;
76
+ it ( 'contains three input elements and one button' , function ( ) {
76
77
expect ( element . find ( 'input' ) . length ) . toBe ( 2 ) ;
77
78
expect ( element . find ( 'button' ) . length ) . toBe ( 1 ) ;
78
79
} ) ;
@@ -321,7 +322,9 @@ describe('timepicker directive', function () {
321
322
322
323
it ( 'responds properly on "wheel" events' , function ( ) {
323
324
var inputs = element . find ( 'input' ) ;
324
- var hoursEl = inputs . eq ( 0 ) , minutesEl = inputs . eq ( 1 ) ;
325
+ var hoursEl = inputs . eq ( 0 ) ,
326
+ minutesEl = inputs . eq ( 1 ) ;
327
+
325
328
var upMouseWheelEvent = wheelThatOtherMouse ( - 1 ) ;
326
329
var downMouseWheelEvent = wheelThatOtherMouse ( 1 ) ;
327
330
@@ -550,7 +553,7 @@ describe('timepicker directive', function () {
550
553
it ( 'initially displays correct time when `show-meridian` is false' , function ( ) {
551
554
expect ( getTimeState ( true ) ) . toEqual ( [ '14' , '10' ] ) ;
552
555
expect ( getModelState ( ) ) . toEqual ( [ 14 , 10 ] ) ;
553
- expect ( getMeridianTd ( ) . css ( 'display' ) ) . toBe ( 'none' ) ;
556
+ expect ( getMeridianButton ( ) . css ( 'display' ) ) . toBe ( 'none' ) ;
554
557
} ) ;
555
558
556
559
it ( 'toggles correctly between different modes' , function ( ) {
@@ -566,7 +569,7 @@ describe('timepicker directive', function () {
566
569
$rootScope . $digest ( ) ;
567
570
expect ( getTimeState ( true ) ) . toEqual ( [ '14' , '10' ] ) ;
568
571
expect ( getModelState ( ) ) . toEqual ( [ 14 , 10 ] ) ;
569
- expect ( getMeridianTd ( ) . css ( 'display' ) ) . toBe ( 'none' ) ;
572
+ expect ( getMeridianButton ( ) . css ( 'display' ) ) . toBe ( 'none' ) ;
570
573
} ) ;
571
574
572
575
it ( 'handles correctly initially empty model on parent element' , function ( ) {
@@ -724,15 +727,17 @@ describe('timepicker directive', function () {
724
727
725
728
changeInputValueTo ( el , 'pizza' ) ;
726
729
expect ( $rootScope . time ) . toBe ( null ) ;
727
- expect ( el . parent ( ) . hasClass ( 'error' ) ) . toBe ( true ) ;
730
+
731
+ expect ( el . parent ( ) . hasClass ( 'has-error' ) ) . toBe ( true ) ;
728
732
expect ( element . hasClass ( 'ng-invalid-time' ) ) . toBe ( true ) ;
729
733
730
734
changeInputValueTo ( el , 8 ) ;
731
735
el . blur ( ) ;
732
736
$rootScope . $digest ( ) ;
733
737
expect ( getTimeState ( ) ) . toEqual ( [ '08' , '40' , 'PM' ] ) ;
734
738
expect ( getModelState ( ) ) . toEqual ( [ 20 , 40 ] ) ;
735
- expect ( el . parent ( ) . hasClass ( 'error' ) ) . toBe ( false ) ;
739
+
740
+ expect ( el . parent ( ) . hasClass ( 'has-error' ) ) . toBe ( false ) ;
736
741
expect ( element . hasClass ( 'ng-invalid-time' ) ) . toBe ( false ) ;
737
742
} ) ;
738
743
@@ -741,13 +746,15 @@ describe('timepicker directive', function () {
741
746
742
747
changeInputValueTo ( el , 'pizza' ) ;
743
748
expect ( $rootScope . time ) . toBe ( null ) ;
744
- expect ( el . parent ( ) . hasClass ( 'error' ) ) . toBe ( true ) ;
749
+
750
+ expect ( el . parent ( ) . hasClass ( 'has-error' ) ) . toBe ( true ) ;
745
751
expect ( element . hasClass ( 'ng-invalid-time' ) ) . toBe ( true ) ;
746
752
747
753
changeInputValueTo ( el , 22 ) ;
748
754
expect ( getTimeState ( ) ) . toEqual ( [ '02' , '22' , 'PM' ] ) ;
749
755
expect ( getModelState ( ) ) . toEqual ( [ 14 , 22 ] ) ;
750
- expect ( el . parent ( ) . hasClass ( 'error' ) ) . toBe ( false ) ;
756
+
757
+ expect ( el . parent ( ) . hasClass ( 'has-error' ) ) . toBe ( false ) ;
751
758
expect ( element . hasClass ( 'ng-invalid-time' ) ) . toBe ( false ) ;
752
759
} ) ;
753
760
@@ -760,7 +767,8 @@ describe('timepicker directive', function () {
760
767
761
768
changeInputValueTo ( el , '16' ) ;
762
769
expect ( $rootScope . time ) . toBe ( null ) ;
763
- expect ( el . parent ( ) . hasClass ( 'error' ) ) . toBe ( true ) ;
770
+
771
+ expect ( el . parent ( ) . hasClass ( 'has-error' ) ) . toBe ( true ) ;
764
772
expect ( element . hasClass ( 'ng-invalid-time' ) ) . toBe ( true ) ;
765
773
766
774
$rootScope . meridian = false ;
@@ -871,3 +879,4 @@ describe('timepicker directive', function () {
871
879
872
880
} ) ;
873
881
882
+
0 commit comments