-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7395 from uktrade/fix/remove-format-without-parsing
Remove `formatWithoutParsing` function and replace it with `formatDate`
- Loading branch information
Showing
35 changed files
with
290 additions
and
220 deletions.
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
4 changes: 2 additions & 2 deletions
4
src/apps/companies/middleware/__test__/last-interaction-date.test.js
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { subMonths } = require('date-fns') | ||
|
||
const { | ||
formatDate, | ||
DATE_FORMAT_INTERACTION_TIMESTAMP, | ||
} = require('../../../client/utils/date-utils') | ||
|
||
function getInteractionTimestamp({ offset }) { | ||
const date = new Date() | ||
|
||
if (offset > 0) { | ||
subMonths(date, offset) | ||
} | ||
|
||
return formatDate(date, DATE_FORMAT_INTERACTION_TIMESTAMP) | ||
} | ||
|
||
module.exports = { | ||
getInteractionTimestamp, | ||
} |
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
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
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
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
31 changes: 31 additions & 0 deletions
31
src/client/modules/Tasks/TaskForm/__test__/transformer.test.js
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { format, addMonths, addDays } from 'date-fns' | ||
|
||
import { getDueDate } from '../transformers' | ||
|
||
describe('getDueDate', () => { | ||
it('should return the transformed value for a custom date', () => { | ||
const customDate = { year: 2024, month: 12, day: 31 } | ||
const expectedTransformedValue = '2024-12-31' | ||
|
||
const result = getDueDate('custom', customDate) | ||
expect(result).to.equal(expectedTransformedValue) | ||
}) | ||
|
||
it('should return the correct due date for the next month', () => { | ||
const today = new Date() | ||
const nextMonthDate = addMonths(today, 1) | ||
const formattedDate = format(nextMonthDate, 'yyyy-MM-dd') | ||
|
||
const result = getDueDate('month') | ||
expect(result).to.equal(formattedDate) | ||
}) | ||
|
||
it('should return the correct due date for the next week', () => { | ||
const today = new Date() | ||
const nextWeekDate = addDays(today, 7) | ||
const formattedDate = format(nextWeekDate, 'yyyy-MM-dd') | ||
|
||
const result = getDueDate('week') | ||
expect(result).to.equal(formattedDate) | ||
}) | ||
}) |
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
Oops, something went wrong.