@@ -59,10 +59,10 @@ describe('datepicker directive', function () {
59
59
return element . find ( 'thead' ) . find ( 'tr' ) . eq ( 1 ) ;
60
60
}
61
61
62
- function getLabels ( ) {
62
+ function getLabels ( dayMode ) {
63
63
var els = getLabelsRow ( ) . find ( 'th' ) ,
64
64
labels = [ ] ;
65
- for ( var i = 1 , n = els . length ; i < n ; i ++ ) {
65
+ for ( var i = dayMode ? 1 : 0 , n = els . length ; i < n ; i ++ ) {
66
66
labels . push ( els . eq ( i ) . text ( ) ) ;
67
67
}
68
68
return labels ;
@@ -77,7 +77,7 @@ describe('datepicker directive', function () {
77
77
return weeks ;
78
78
}
79
79
80
- function getOptions ( dayMode ) {
80
+ function getOptions ( dayMode ) {
81
81
var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
82
82
var rows = [ ] ;
83
83
@@ -91,11 +91,11 @@ describe('datepicker directive', function () {
91
91
return rows ;
92
92
}
93
93
94
- function clickOption ( index ) {
94
+ function clickOption ( index ) {
95
95
getAllOptionsEl ( ) . eq ( index ) . click ( ) ;
96
96
}
97
97
98
- function getAllOptionsEl ( dayMode ) {
98
+ function getAllOptionsEl ( dayMode ) {
99
99
return element . find ( 'tbody' ) . find ( 'button' ) ;
100
100
}
101
101
@@ -108,7 +108,7 @@ describe('datepicker directive', function () {
108
108
}
109
109
}
110
110
111
- function expectSelectedElement ( index ) {
111
+ function expectSelectedElement ( index ) {
112
112
var buttons = getAllOptionsEl ( ) ;
113
113
angular . forEach ( buttons , function ( button , idx ) {
114
114
expect ( angular . element ( button ) . hasClass ( 'btn-info' ) ) . toBe ( idx === index ) ;
@@ -153,7 +153,7 @@ describe('datepicker directive', function () {
153
153
154
154
it ( 'shows the label row & the correct day labels' , function ( ) {
155
155
expect ( getLabelsRow ( ) . css ( 'display' ) ) . not . toBe ( 'none' ) ;
156
- expect ( getLabels ( ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
156
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
157
157
} ) ;
158
158
159
159
it ( 'renders the calendar days correctly' , function ( ) {
@@ -211,7 +211,7 @@ describe('datepicker directive', function () {
211
211
clickPreviousButton ( ) ;
212
212
213
213
expect ( getTitle ( ) ) . toBe ( 'August 2010' ) ;
214
- expect ( getLabels ( ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
214
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
215
215
expect ( getOptions ( true ) ) . toEqual ( [
216
216
[ '01' , '02' , '03' , '04' , '05' , '06' , '07' ] ,
217
217
[ '08' , '09' , '10' , '11' , '12' , '13' , '14' ] ,
@@ -236,7 +236,7 @@ describe('datepicker directive', function () {
236
236
clickNextButton ( ) ;
237
237
238
238
expect ( getTitle ( ) ) . toBe ( 'October 2010' ) ;
239
- expect ( getLabels ( ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
239
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
240
240
expect ( getOptions ( true ) ) . toEqual ( [
241
241
[ '26' , '27' , '28' , '29' , '30' , '01' , '02' ] ,
242
242
[ '03' , '04' , '05' , '06' , '07' , '08' , '09' ] ,
@@ -261,7 +261,7 @@ describe('datepicker directive', function () {
261
261
clickOption ( 33 ) ;
262
262
expect ( $rootScope . date ) . toEqual ( new Date ( 'October 01, 2010 15:30:00' ) ) ;
263
263
expect ( getTitle ( ) ) . toBe ( 'October 2010' ) ;
264
- expect ( getLabels ( ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
264
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
265
265
expect ( getOptions ( true ) ) . toEqual ( [
266
266
[ '26' , '27' , '28' , '29' , '30' , '01' , '02' ] ,
267
267
[ '03' , '04' , '05' , '06' , '07' , '08' , '09' ] ,
@@ -735,7 +735,7 @@ describe('datepicker directive', function () {
735
735
} ) ;
736
736
737
737
it ( 'shows the day labels rotated' , function ( ) {
738
- expect ( getLabels ( ) ) . toEqual ( [ 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' ] ) ;
738
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' ] ) ;
739
739
} ) ;
740
740
741
741
it ( 'renders the calendar days correctly' , function ( ) {
@@ -755,20 +755,18 @@ describe('datepicker directive', function () {
755
755
} ) ;
756
756
757
757
describe ( 'attribute `show-weeks`' , function ( ) {
758
- var weekHeader , weekElement ;
759
758
beforeEach ( function ( ) {
760
759
$rootScope . showWeeks = false ;
761
760
element = $compile ( '<datepicker ng-model="date" show-weeks="showWeeks"></datepicker>' ) ( $rootScope ) ;
762
761
$rootScope . $digest ( ) ;
763
-
764
- weekHeader = getLabelsRow ( ) . find ( 'th' ) . eq ( 0 ) ;
765
- weekElement = element . find ( 'tbody' ) . find ( 'tr' ) . eq ( 1 ) . find ( 'td' ) . eq ( 0 ) ;
766
762
} ) ;
767
763
768
764
it ( 'hides week numbers based on variable' , function ( ) {
769
- expect ( weekHeader . text ( ) ) . toEqual ( '' ) ;
770
- expect ( weekHeader ) . toBeHidden ( ) ;
771
- expect ( weekElement ) . toBeHidden ( ) ;
765
+ expect ( getLabelsRow ( ) . find ( 'th' ) . length ) . toEqual ( 7 ) ;
766
+ var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
767
+ for ( var i = 0 ; i < 5 ; i ++ ) {
768
+ expect ( tr . eq ( i ) . find ( 'td' ) . length ) . toEqual ( 7 ) ;
769
+ }
772
770
} ) ;
773
771
} ) ;
774
772
@@ -1035,7 +1033,7 @@ describe('datepicker directive', function () {
1035
1033
} ) ;
1036
1034
1037
1035
it ( 'shows day labels' , function ( ) {
1038
- expect ( getLabels ( ) ) . toEqual ( [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ) ;
1036
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ) ;
1039
1037
} ) ;
1040
1038
1041
1039
it ( 'changes the day format' , function ( ) {
@@ -1101,7 +1099,7 @@ describe('datepicker directive', function () {
1101
1099
1102
1100
it ( 'changes the `starting-day` & day headers & format' , function ( ) {
1103
1101
expect ( getLabels ( ) ) . toEqual ( [ 'Saturday' , 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' ] ) ;
1104
- expect ( getOptions ( true ) ) . toEqual ( [
1102
+ expect ( getOptions ( false ) ) . toEqual ( [
1105
1103
[ '28' , '29' , '30' , '31' , '1' , '2' , '3' ] ,
1106
1104
[ '4' , '5' , '6' , '7' , '8' , '9' , '10' ] ,
1107
1105
[ '11' , '12' , '13' , '14' , '15' , '16' , '17' ] ,
@@ -1112,10 +1110,10 @@ describe('datepicker directive', function () {
1112
1110
} ) ;
1113
1111
1114
1112
it ( 'changes initial visibility for weeks' , function ( ) {
1115
- expect ( getLabelsRow ( ) . find ( 'th' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1113
+ expect ( getLabelsRow ( ) . find ( 'th' ) . length ) . toEqual ( 7 ) ;
1116
1114
var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
1117
1115
for ( var i = 0 ; i < 5 ; i ++ ) {
1118
- expect ( tr . eq ( i ) . find ( 'td' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1116
+ expect ( tr . eq ( i ) . find ( 'td' ) . length ) . toEqual ( 7 ) ;
1119
1117
}
1120
1118
} ) ;
1121
1119
@@ -1212,7 +1210,7 @@ describe('datepicker directive', function () {
1212
1210
1213
1211
it ( 'renders the calendar correctly' , function ( ) {
1214
1212
expect ( getLabelsRow ( ) . css ( 'display' ) ) . not . toBe ( 'none' ) ;
1215
- expect ( getLabels ( ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
1213
+ expect ( getLabels ( true ) ) . toEqual ( [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ) ;
1216
1214
expect ( getOptions ( true ) ) . toEqual ( [
1217
1215
[ '29' , '30' , '31' , '01' , '02' , '03' , '04' ] ,
1218
1216
[ '05' , '06' , '07' , '08' , '09' , '10' , '11' ] ,
@@ -1495,23 +1493,21 @@ describe('datepicker directive', function () {
1495
1493
describe ( 'attribute `datepickerOptions`' , function ( ) {
1496
1494
1497
1495
describe ( 'show-weeks' , function ( ) {
1498
- var weekHeader , weekElement ;
1499
1496
beforeEach ( function ( ) {
1500
1497
$rootScope . opts = {
1501
1498
'show-weeks' : false
1502
1499
} ;
1503
1500
var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1504
1501
$rootScope . $digest ( ) ;
1505
1502
assignElements ( wrapElement ) ;
1506
-
1507
- weekHeader = getLabelsRow ( ) . find ( 'th' ) . eq ( 0 ) ;
1508
- weekElement = element . find ( 'tbody' ) . find ( 'tr' ) . eq ( 1 ) . find ( 'td' ) . eq ( 0 ) ;
1509
1503
} ) ;
1510
1504
1511
1505
it ( 'hides week numbers based on variable' , function ( ) {
1512
- expect ( weekHeader . text ( ) ) . toEqual ( '' ) ;
1513
- expect ( weekHeader ) . toBeHidden ( ) ;
1514
- expect ( weekElement ) . toBeHidden ( ) ;
1506
+ expect ( getLabelsRow ( ) . find ( 'th' ) . length ) . toEqual ( 7 ) ;
1507
+ var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
1508
+ for ( var i = 0 ; i < 5 ; i ++ ) {
1509
+ expect ( tr . eq ( i ) . find ( 'td' ) . length ) . toEqual ( 7 ) ;
1510
+ }
1515
1511
} ) ;
1516
1512
} ) ;
1517
1513
@@ -1798,10 +1794,10 @@ describe('datepicker directive', function () {
1798
1794
$rootScope . $digest ( ) ;
1799
1795
assignElements ( wrapElement ) ;
1800
1796
1801
- expect ( getLabelsRow ( ) . find ( 'th' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1797
+ expect ( getLabelsRow ( ) . find ( 'th' ) . length ) . toEqual ( 7 ) ;
1802
1798
var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
1803
1799
for ( var i = 0 ; i < 5 ; i ++ ) {
1804
- expect ( tr . eq ( i ) . find ( 'td' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1800
+ expect ( tr . eq ( i ) . find ( 'td' ) . length ) . toEqual ( 7 ) ;
1805
1801
}
1806
1802
} ) ;
1807
1803
@@ -1946,10 +1942,10 @@ describe('datepicker directive', function () {
1946
1942
} ) ) ;
1947
1943
1948
1944
it ( 'changes initial visibility for weeks' , function ( ) {
1949
- expect ( getLabelsRow ( ) . find ( 'th' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1945
+ expect ( getLabelsRow ( ) . find ( 'th' ) . length ) . toEqual ( 7 ) ;
1950
1946
var tr = element . find ( 'tbody' ) . find ( 'tr' ) ;
1951
1947
for ( var i = 0 ; i < 5 ; i ++ ) {
1952
- expect ( tr . eq ( i ) . find ( 'td' ) . eq ( 0 ) ) . toBeHidden ( ) ;
1948
+ expect ( tr . eq ( i ) . find ( 'td' ) . length ) . toEqual ( 7 ) ;
1953
1949
}
1954
1950
} ) ;
1955
1951
} ) ;
0 commit comments