This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix(datepicker): week count issues #2306
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ec47709
fix(datepicker): week count issues
a5sk4s 4dc41fd
fix(datepicker): add missing semicolon
a5sk4s 8f627de
fix(datepicker): no need for exact days match in test
a5sk4s e1a67c9
Merge branch 'master' of github.com:angular-ui/bootstrap into fix-weeks
a5sk4s a46f19f
fix(spec): left ddescribe in spec file
a5sk4s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,7 @@ describe('datepicker directive', function () { | |
}); | ||
|
||
it('renders the week numbers based on ISO 8601', function() { | ||
expect(getWeeks()).toEqual(['34', '35', '36', '37', '38', '39']); | ||
expect(getWeeks()).toEqual(['35', '36', '37', '38', '39', '40']); | ||
}); | ||
|
||
it('value is correct', function() { | ||
|
@@ -1711,4 +1711,75 @@ describe('datepicker directive', function () { | |
expect(getTitle()).toBe('2013'); | ||
}); | ||
}); | ||
|
||
describe('thurdays determine week count', function() { | ||
|
||
beforeEach(inject(function() { | ||
$rootScope.date = new Date('June 07, 2014'); | ||
})); | ||
|
||
it('with the default starting day (sunday)', function() { | ||
element = $compile('<datepicker ng-model="date"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['23', '24', '25', '26', '27', '28']); | ||
}); | ||
|
||
describe('when starting date', function() { | ||
it('is monday', function() { | ||
element = $compile('<datepicker ng-model="date" starting-day="1"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['22', '23', '24', '25', '26', '27']); | ||
}); | ||
|
||
it('is thursday', function() { | ||
element = $compile('<datepicker ng-model="date" starting-day="4"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['22', '23', '24', '25', '26', '27']); | ||
}); | ||
|
||
it('is saturday', function() { | ||
element = $compile('<datepicker ng-model="date" starting-day="6"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['23', '24', '25', '26', '27', '28']); | ||
}); | ||
}); | ||
|
||
describe('first week in january', function() { | ||
beforeEach(inject(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This empty beforeEach can be removed |
||
})); | ||
|
||
it('in current year', function() { | ||
$rootScope.date = new Date('January 07, 2014'); | ||
element = $compile('<datepicker ng-model="date"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['1', '2', '3', '4', '5', '6']); | ||
}); | ||
|
||
it('in last year', function() { | ||
$rootScope.date = new Date('January 07, 2010'); | ||
element = $compile('<datepicker ng-model="date"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['53', '1', '2', '3', '4', '5']); | ||
}); | ||
}); | ||
|
||
describe('last week(s) in december', function() { | ||
beforeEach(inject(function() { | ||
$rootScope.date = new Date('December 07, 2014'); | ||
})); | ||
|
||
it('in next year', function() { | ||
element = $compile('<datepicker ng-model="date"></datepicker>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
expect(getWeeks()).toEqual(['49', '50', '51', '52', '1', '2']); | ||
}); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably better re-written as a for loop. It was previously simpler as a while loop but now it makes more sense as a for loop as it's more readable.