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