Skip to content

Commit

Permalink
Fix the test for refreshing time
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Jul 21, 2024
1 parent aa2da09 commit bffa04d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ describe('AccelerationDetailsTab', () => {
// Mock the Date.now() method to always return a specific timestamp
jest.spyOn(Date, 'now').mockImplementation(() => 1627819985000); // 2021-08-01T11:53:05.000Z

// Mock the Intl.DateTimeFormat to use a specific timezone (e.g., UTC-5)
// Mock the Intl.DateTimeFormat to use a specific timezone (e.g., UTC)
jest.spyOn(Intl, 'DateTimeFormat').mockImplementation(() => {
return {
format: (date) =>
new Date(date).toLocaleString('en-US', {
timeZone: 'America/New_York',
timeZone: 'UTC',
year: 'numeric',
month: 'numeric',
day: 'numeric',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ describe('AssociatedObjectsTab', () => {
global.Date = OriginalDate;
});

// Mock the Intl.DateTimeFormat to use UTC for consistency
jest.spyOn(Intl, 'DateTimeFormat').mockImplementation(() => {
return {
format: (date) =>
new Date(date).toLocaleString('en-US', {
timeZone: 'UTC',
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hour12: true,
}),
} as any;
});

test('renders without crashing', () => {
renderComponent();
expect(
Expand Down

0 comments on commit bffa04d

Please sign in to comment.