Skip to content

Commit

Permalink
Force a consistent non-UTC timezone for tests, so we can validate out…
Browse files Browse the repository at this point in the history
…puts. Minor cleanup.
  • Loading branch information
dannon committed Dec 9, 2024
1 parent 82ef3d2 commit 6996a8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/src/utils/dates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ describe("dates.ts", () => {
expect(formatted).toBe("Sunday Oct 1st 8:00:00 2023 GMT-4");
});
});
});
});
4 changes: 2 additions & 2 deletions client/src/utils/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function galaxyTimeToDate(galaxyTime: string): Date {
}

/**
* Formats a UTC Date object into a human-readable string.
* Formats a UTC Date object into a human-readable string, localized to the user's time zone.
* @param {Date} utcDate - The UTC Date object.
* @returns {string} The formatted date string.
*/
Expand All @@ -29,7 +29,7 @@ export function localizeUTCPretty(utcDate: Date): string {
}

/**
* Converts a Galaxy time string to a human-readable formatted date string.
* Converts a Galaxy time string to a human-readable formatted date string, localized to the user's time zone.
* @param {string} galaxyTime - The Galaxy time string in ISO format.
* @returns {string} The formatted date string.
*/
Expand Down
3 changes: 3 additions & 0 deletions client/tests/jest/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Vue.config.devtools = false;
and this makes the tag tests work correctly */
global.setImmediate = global.setTimeout;

// Consistent timezone for tests so we can compare date strings
process.env.TZ = "America/New_York";

// Always mock the following imports
jest.mock("@/composables/hashedUserId");
jest.mock("@/composables/userLocalStorage");

0 comments on commit 6996a8d

Please sign in to comment.