-
Notifications
You must be signed in to change notification settings - Fork 278
WS-NA: Temporal Migration (PR 1: Adds test coverage) #14099
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
Open
Isabella-Mitchell
wants to merge
15
commits into
latest
Choose a base branch
from
WS-NA-temporal-migrate-prep-tests
base: latest
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 all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a54c3f8
WS-NA: Kick off prompt, add tests for missing edge cases
Isabella-Mitchell 921226d
Merge branch 'latest' into WS-NA-temporal-migrate-prep-tests
Isabella-Mitchell 44e6c05
WS-NA-Temporal: Cleans tests
Isabella-Mitchell 1f631f0
WS-NA-Temporal: Adds tests for further timezones
Isabella-Mitchell 50424db
WS-NA-Temporal: Adds test coverage for locales on formatUnixTimestamp
Isabella-Mitchell c6fdcd3
WS-NA-Temporal: Tidies article timestamp tests
Isabella-Mitchell e0838d5
WS-NA-temporal: Fixes typo in service config
Isabella-Mitchell 4febfc5
WS-NA-temporal: Adds un-abbreviated form of DST to readme
Isabella-Mitchell 81a7bd6
WS-NA-temporal: tidies tests
Isabella-Mitchell 4866b6a
WS-NA-Temporal: removes tests I think are extra:
Isabella-Mitchell 25557f3
WS-NA: Adds initial storybook checks
Isabella-Mitchell b6cbabe
WS-NA: Adds some chromatic tests for DST and timezones/ locales
Isabella-Mitchell 10bb027
Merge branch 'latest' into WS-NA-temporal-migrate-prep-tests
Isabella-Mitchell 4d15b0d
WS-NA-Temporal: Adds story for Persian Jalali
Isabella-Mitchell bb34a8c
WS-NA-temporal: Commit CR suggestion
Isabella-Mitchell 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -132,6 +132,143 @@ describe('Timestamp utility functions', () => { | |
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should correctly format timezone labels around DST start in Europe/London', () => { | ||
| const beforeDSTStart = Date.UTC(2021, 2, 28, 0, 30, 0); // 00:30 GMT | ||
| const afterDSTStart = Date.UTC(2021, 2, 28, 1, 30, 0); // 02:30 BST | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: beforeDSTStart, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone, | ||
| locale, | ||
|
Contributor
Author
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. Note, uses default |
||
| }), | ||
| ).toEqual('28 March 2021, 00:30 GMT'); | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: afterDSTStart, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone, | ||
| locale, | ||
| }), | ||
| ).toEqual('28 March 2021, 02:30 BST'); | ||
| }); | ||
|
|
||
| it('should correctly format timezone labels around DST end in Europe/London', () => { | ||
| const beforeDSTEnd = Date.UTC(2021, 9, 31, 0, 30, 0); // 01:30 BST | ||
| const afterDSTEnd = Date.UTC(2021, 9, 31, 1, 30, 0); // 01:30 GMT | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: beforeDSTEnd, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone, | ||
| locale, | ||
| }), | ||
| ).toEqual('31 October 2021, 01:30 BST'); | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: afterDSTEnd, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone, | ||
| locale, | ||
| }), | ||
| ).toEqual('31 October 2021, 01:30 GMT'); | ||
| }); | ||
|
|
||
| it('should apply a fixed UTC+1 offset for Africa/Lagos (no DST)', () => { | ||
| const utcTimestamp = Date.UTC(2021, 5, 15, 12, 0, 0); // 15 June 2021 12:00 UTC | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: utcTimestamp, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone: 'Africa/Lagos', | ||
| locale, | ||
| }), | ||
| ).toEqual('15 June 2021, 13:00 WAT'); | ||
| }); | ||
|
|
||
| it('should apply a +05:45 offset for Asia/Kathmandu (no DST, non-whole-hour offset)', () => { | ||
| const utcTimestamp = Date.UTC(2021, 5, 15, 12, 0, 0); // 15 June 2021 12:00 UTC | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: utcTimestamp, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone: 'Asia/Kathmandu', | ||
| locale, | ||
| }), | ||
| ).toEqual('15 June 2021, 17:45 +0545'); | ||
| }); | ||
|
|
||
| it('should apply a negative UTC-3 offset for America/Sao_Paulo', () => { | ||
| const utcTimestamp = Date.UTC(2021, 5, 15, 12, 0, 0); // 15 June 2021 12:00 UTC | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: utcTimestamp, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone: 'America/Sao_Paulo', | ||
| locale, | ||
| }), | ||
| ).toEqual('15 June 2021, 09:00 -03'); | ||
| }); | ||
|
|
||
| it('should format correctly for GMT (non-region-style IANA identifier)', () => { | ||
| const utcTimestamp = Date.UTC(2021, 5, 15, 12, 0, 0); // 15 June 2021 12:00 UTC | ||
|
|
||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp: utcTimestamp, | ||
| format: 'D MMMM YYYY, HH:mm z', | ||
| timezone: 'GMT', | ||
| locale, | ||
| }), | ||
| ).toEqual('15 June 2021, 12:00 GMT'); | ||
| }); | ||
|
|
||
| it('should translate month names for a non-Latin locale', () => { | ||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp, | ||
| format: 'D MMMM YYYY', | ||
| timezone: 'GMT', | ||
| locale: 'ar', | ||
| }), | ||
| ).toEqual('١٩ أكتوبر ٢٠١٨'); | ||
| }); | ||
|
|
||
| it('should apply locale-sensitive format tokens (LL, LT) for a non-Latin locale', () => { | ||
| expect( | ||
| formatUnixTimestamp({ | ||
| timestamp, | ||
| format: null, | ||
| timezone: 'GMT', | ||
| locale: 'ar', | ||
| }), | ||
| ).toEqual('١٩ أكتوبر ٢٠١٨، ١٧:١٠ GMT'); | ||
| }); | ||
|
|
||
| it('should return relative timestamp in the provided locale', () => { | ||
| const nowSpy = jest.spyOn(Date, 'now').mockReturnValue(1704110400000); // 1 January 2024 12:00:00 UTC | ||
| try { | ||
| const nineHoursAgo = timestampGenerator({ hours: 9 }); | ||
| const output = formatUnixTimestamp({ | ||
| timestamp: nineHoursAgo, | ||
| format: 'D MMMM YYYY', | ||
| timezone: 'GMT', | ||
| locale: 'ar', | ||
| isRelative: true, | ||
| }); | ||
| expect(output).toEqual('منذ ٩ ساعات'); | ||
| } finally { | ||
| nowSpy.mockRestore(); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
This file contains hidden or 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.
Note, gets datetimeLocale and timezone from the service config (similar to the other tests above)