-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: FLUI-146 fix date test and typo #565
Open
claudia1296
wants to merge
2
commits into
master
Choose a base branch
from
fix/flui-146
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ describe('Relative date', () => { | |
pastYear: 'Past Years', | ||
thisYear: 'This Years', | ||
today: 'today', | ||
yesteday: 'yesteday', | ||
yesterday: 'yesterday', | ||
}; | ||
test('should return now', () => { | ||
const date = new Date(); | ||
|
@@ -17,19 +17,23 @@ describe('Relative date', () => { | |
const date = new Date(Date.now() - 1000 * 60); | ||
expect(getRelativeDate(date, format)).toEqual('today'); | ||
}); | ||
test('should return yesteday', () => { | ||
test('should return yesterday', () => { | ||
const today = new Date(); | ||
const yesterday = new Date(today); | ||
yesterday.setDate(today.getDate() - 1); | ||
expect(getRelativeDate(yesterday, format)).toEqual('yesteday'); | ||
expect(getRelativeDate(yesterday, format)).toEqual('yesterday'); | ||
}); | ||
test('should return this years date', () => { | ||
const today = new Date(); | ||
const startYear = new Date(today.getFullYear(), 0, 1); | ||
const endPeriodTime = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 2); | ||
|
||
const randomDate = new Date( | ||
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. Pourquoi avoir une date random et non fixe ? |
||
startYear.getTime() + Math.random() * (endPeriodTime.getTime() - startYear.getTime()), | ||
); | ||
|
||
expect(getRelativeDate(randomDate, format)).toEqual('This Years'); | ||
}); | ||
// FLUI-146 failed the seven first days of a year | ||
// test('should return this years date', () => { | ||
// const today = new Date(); | ||
// const pastDate = new Date(today); | ||
// pastDate.setDate(today.getDate() - 7); | ||
// expect(getRelativeDate(pastDate, format)).toEqual('This Years'); | ||
// }); | ||
test('should return past years date', () => { | ||
const today = new Date(); | ||
const pastDate = new Date(today); | ||
|
@@ -56,56 +60,56 @@ describe('Relative date', () => { | |
}); | ||
test('should return correct time am en', () => { | ||
const formatTime = { | ||
yesteday: 'Yesteday at {hour}{ampm}', | ||
yesterday: 'Yesterday at {hour}{ampm}', | ||
}; | ||
setLocale('en'); | ||
|
||
const yesteday = new Date(); | ||
yesteday.setDate(yesteday.getDate() - 1); | ||
yesteday.setHours(11); | ||
yesteday.setMinutes(52); | ||
const yesterday = new Date(); | ||
yesterday.setDate(yesterday.getDate() - 1); | ||
yesterday.setHours(11); | ||
yesterday.setMinutes(52); | ||
|
||
expect(getRelativeDate(yesteday, formatTime)).toEqual('Yesteday at 11:52am'); | ||
expect(getRelativeDate(yesterday, formatTime)).toEqual('Yesterday at 11:52am'); | ||
}); | ||
test('should return correct time am fr', () => { | ||
const formatTime = { | ||
yesteday: 'Hier à {hour}{ampm}', | ||
yesterday: 'Hier à {hour}{ampm}', | ||
}; | ||
setLocale('fr'); | ||
|
||
const yesteday = new Date(); | ||
yesteday.setDate(yesteday.getDate() - 1); | ||
yesteday.setHours(11); | ||
yesteday.setMinutes(52); | ||
const yesterday = new Date(); | ||
yesterday.setDate(yesterday.getDate() - 1); | ||
yesterday.setHours(11); | ||
yesterday.setMinutes(52); | ||
|
||
expect(getRelativeDate(yesteday, formatTime)).toEqual('Hier à 11h52'); | ||
expect(getRelativeDate(yesterday, formatTime)).toEqual('Hier à 11h52'); | ||
}); | ||
|
||
test('should return correct time pm en', () => { | ||
const formatTime = { | ||
yesteday: 'Yesteday at {hour}{ampm}', | ||
yesterday: 'Yesterday at {hour}{ampm}', | ||
}; | ||
setLocale('en'); | ||
|
||
const yesteday = new Date(); | ||
yesteday.setDate(yesteday.getDate() - 1); | ||
yesteday.setHours(16); | ||
yesteday.setMinutes(52); | ||
const yesterday = new Date(); | ||
yesterday.setDate(yesterday.getDate() - 1); | ||
yesterday.setHours(16); | ||
yesterday.setMinutes(52); | ||
|
||
expect(getRelativeDate(yesteday, formatTime)).toEqual('Yesteday at 4:52pm'); | ||
expect(getRelativeDate(yesterday, formatTime)).toEqual('Yesterday at 4:52pm'); | ||
}); | ||
|
||
test('should return correct time pm fr', () => { | ||
const formatTime = { | ||
yesteday: 'Hier à {hour}{ampm}', | ||
yesterday: 'Hier à {hour}{ampm}', | ||
}; | ||
setLocale('fr'); | ||
|
||
const yesteday = new Date(); | ||
yesteday.setDate(yesteday.getDate() - 1); | ||
yesteday.setHours(16); | ||
yesteday.setMinutes(52); | ||
const yesterday = new Date(); | ||
yesterday.setDate(yesterday.getDate() - 1); | ||
yesterday.setHours(16); | ||
yesterday.setMinutes(52); | ||
|
||
expect(getRelativeDate(yesteday, formatTime)).toEqual('Hier à 16h52'); | ||
expect(getRelativeDate(yesterday, formatTime)).toEqual('Hier à 16h52'); | ||
}); | ||
}); |
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.
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.
should return this year date
non ?