@@ -159,7 +159,7 @@ describe('datepicker directive', function () {
159
159
} ) ;
160
160
161
161
it ( 'renders the week numbers based on ISO 8601' , function ( ) {
162
- expect ( getWeeks ( ) ) . toEqual ( [ '34' , ' 35', '36' , '37' , '38' , '39' ] ) ;
162
+ expect ( getWeeks ( ) ) . toEqual ( [ '35' , '36' , '37' , '38' , '39' , '40 '] ) ;
163
163
} ) ;
164
164
165
165
it ( 'value is correct' , function ( ) {
@@ -2032,4 +2032,75 @@ describe('datepicker directive', function () {
2032
2032
expect ( new Date ( $rootScope . date . date ) ) . toEqual ( new Date ( 'April 15, 2015 00:00:00' ) ) ;
2033
2033
} ) ;
2034
2034
} ) ;
2035
+
2036
+ describe ( 'thurdays determine week count' , function ( ) {
2037
+
2038
+ beforeEach ( inject ( function ( ) {
2039
+ $rootScope . date = new Date ( 'June 07, 2014' ) ;
2040
+ } ) ) ;
2041
+
2042
+ it ( 'with the default starting day (sunday)' , function ( ) {
2043
+ element = $compile ( '<datepicker ng-model="date"></datepicker>' ) ( $rootScope ) ;
2044
+ $rootScope . $digest ( ) ;
2045
+
2046
+ expect ( getWeeks ( ) ) . toEqual ( [ '23' , '24' , '25' , '26' , '27' , '28' ] ) ;
2047
+ } ) ;
2048
+
2049
+ describe ( 'when starting date' , function ( ) {
2050
+ it ( 'is monday' , function ( ) {
2051
+ element = $compile ( '<datepicker ng-model="date" starting-day="1"></datepicker>' ) ( $rootScope ) ;
2052
+ $rootScope . $digest ( ) ;
2053
+
2054
+ expect ( getWeeks ( ) ) . toEqual ( [ '22' , '23' , '24' , '25' , '26' , '27' ] ) ;
2055
+ } ) ;
2056
+
2057
+ it ( 'is thursday' , function ( ) {
2058
+ element = $compile ( '<datepicker ng-model="date" starting-day="4"></datepicker>' ) ( $rootScope ) ;
2059
+ $rootScope . $digest ( ) ;
2060
+
2061
+ expect ( getWeeks ( ) ) . toEqual ( [ '22' , '23' , '24' , '25' , '26' , '27' ] ) ;
2062
+ } ) ;
2063
+
2064
+ it ( 'is saturday' , function ( ) {
2065
+ element = $compile ( '<datepicker ng-model="date" starting-day="6"></datepicker>' ) ( $rootScope ) ;
2066
+ $rootScope . $digest ( ) ;
2067
+
2068
+ expect ( getWeeks ( ) ) . toEqual ( [ '23' , '24' , '25' , '26' , '27' , '28' ] ) ;
2069
+ } ) ;
2070
+ } ) ;
2071
+
2072
+ describe ( 'first week in january' , function ( ) {
2073
+ beforeEach ( inject ( function ( ) {
2074
+ } ) ) ;
2075
+
2076
+ it ( 'in current year' , function ( ) {
2077
+ $rootScope . date = new Date ( 'January 07, 2014' ) ;
2078
+ element = $compile ( '<datepicker ng-model="date"></datepicker>' ) ( $rootScope ) ;
2079
+ $rootScope . $digest ( ) ;
2080
+
2081
+ expect ( getWeeks ( ) ) . toEqual ( [ '1' , '2' , '3' , '4' , '5' , '6' ] ) ;
2082
+ } ) ;
2083
+
2084
+ it ( 'in last year' , function ( ) {
2085
+ $rootScope . date = new Date ( 'January 07, 2010' ) ;
2086
+ element = $compile ( '<datepicker ng-model="date"></datepicker>' ) ( $rootScope ) ;
2087
+ $rootScope . $digest ( ) ;
2088
+
2089
+ expect ( getWeeks ( ) ) . toEqual ( [ '53' , '1' , '2' , '3' , '4' , '5' ] ) ;
2090
+ } ) ;
2091
+ } ) ;
2092
+
2093
+ describe ( 'last week(s) in december' , function ( ) {
2094
+ beforeEach ( inject ( function ( ) {
2095
+ $rootScope . date = new Date ( 'December 07, 2014' ) ;
2096
+ } ) ) ;
2097
+
2098
+ it ( 'in next year' , function ( ) {
2099
+ element = $compile ( '<datepicker ng-model="date"></datepicker>' ) ( $rootScope ) ;
2100
+ $rootScope . $digest ( ) ;
2101
+
2102
+ expect ( getWeeks ( ) ) . toEqual ( [ '49' , '50' , '51' , '52' , '1' , '2' ] ) ;
2103
+ } ) ;
2104
+ } ) ;
2105
+ } ) ;
2035
2106
} ) ;
0 commit comments