Skip to content

Commit

Permalink
Use last day of the week to get the week number (#693)
Browse files Browse the repository at this point in the history
* Use last day of the week to get the week number

Fixes #692

* Fix unit test

* Fix rendering unit test
  • Loading branch information
gpbl authored Apr 14, 2018
1 parent 941de57 commit 40ad2d3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class Month extends Component {
{weeks.map(week => {
let weekNumber;
if (showWeekNumbers) {
weekNumber = DateUtils.getWeekNumber(week[0]);
weekNumber = DateUtils.getWeekNumber(week[6]);
}
return (
<div
Expand Down
2 changes: 1 addition & 1 deletion test/daypicker/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('DayPicker’s events handlers', () => {
.find('.DayPicker-WeekNumber')
.at(1)
.simulate('click');
expect(handleWeekClick.mock.calls[0][0]).toBe(6);
expect(handleWeekClick.mock.calls[0][0]).toBe(7);
expect(handleWeekClick.mock.calls[0][1]).toHaveLength(7);
});
it('should call `onWeekClick` when pressing ENTER on a week number', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/daypicker/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe('DayPicker’s rendering', () => {
<DayPicker showWeekNumbers initialMonth={new Date(2015, 1)} />
);
expect(wrapper.find('.DayPicker-WeekNumber')).toHaveLength(4);
expect(wrapper.find('.DayPicker-WeekNumber').at(1)).toHaveText('6');
expect(wrapper.find('.DayPicker-WeekNumber').at(1)).toHaveText('7');
});
it('should use the specified class names', () => {
const wrapper = mount(
Expand Down

0 comments on commit 40ad2d3

Please sign in to comment.