mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-22 10:04:09 -05:00
fix(tests): prevent frontend test dependency on system locale (#6649)
This test depended on system locale. It always failed with `LANG=fr_FR make test-frontend` and always passed with `LANG=C make test-frontend`. - prevent this dependency by explicitly passing 'en-US' - avoid process.env.TZ boilerplate with vi.stubEnv Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6649 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Beowulf <beowulf@beocode.eu>
This commit is contained in:
parent
c92fe83c40
commit
a40284bec4
1 changed files with 3 additions and 5 deletions
|
@ -18,9 +18,7 @@ test('toAbsoluteLocaleDate', () => {
|
|||
expect(toAbsoluteLocaleDate('10000-01-01', '', {})).toEqual('Invalid Date');
|
||||
|
||||
// test different timezone
|
||||
const oldTZ = process.env.TZ;
|
||||
process.env.TZ = 'America/New_York';
|
||||
expect(new Date('2024-03-15').toLocaleString()).toEqual('3/14/2024, 8:00:00 PM');
|
||||
expect(toAbsoluteLocaleDate('2024-03-15')).toEqual('3/15/2024, 12:00:00 AM');
|
||||
process.env.TZ = oldTZ;
|
||||
vi.stubEnv('TZ', 'America/New_York');
|
||||
expect(new Date('2024-03-15').toLocaleString('en-US')).toEqual('3/14/2024, 8:00:00 PM');
|
||||
expect(toAbsoluteLocaleDate('2024-03-15', 'en-US')).toEqual('3/15/2024, 12:00:00 AM');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue