Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
lastMonday not working as expected :(
Browse files Browse the repository at this point in the history
`npm run unittest -- --grep="update date handling"`

Auditors: @aekeus
  • Loading branch information
bsclifton committed Dec 4, 2017
1 parent 8f8fbdf commit b5639b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/unit/app/browser/datesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require('../../braveUnit')

describe('update date handling', function () {
const exampleDate = 1510708981887 // Tuesday November 14th 2017, 6:23:01 PM
const exampleDate2 = 1512404291746 // Monday December 04th 2017, 9:18:11 AM
let fakeClock
before(function () {
fakeClock = sinon.useFakeTimers(exampleDate)
Expand Down Expand Up @@ -37,8 +38,11 @@ describe('update date handling', function () {

describe('lastMonday', function () {
it('returns YYYY-MM-DD of closest Monday in the past to current date', function () {
var d = new Date(exampleDate)
let d = new Date(exampleDate)
assert.equal(dates.lastMonday(d), '2017-11-13', 'previous Monday')

d = new Date(exampleDate2)
assert.equal(dates.lastMonday(d), '2017-11-28', 'previous Monday')
})
})
})

2 comments on commit b5639b9

@aekeus
Copy link
Member

@aekeus aekeus commented on b5639b9 Dec 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the function needs to be clearer. It should be todayOrLastMonday.

If the current date is a Monday, it should return the current date.

@bsclifton
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah- good call (I see it now- day is a number 0-6, not day of month) 😄 I'll add a test to make it clear

Please sign in to comment.