Skip to content

Commit 8ee6a66

Browse files
committed
ci: fix timezone issue
1 parent cf6468e commit 8ee6a66

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"type": "module",
1111
"scripts": {
1212
"start": "node bin/index.js",
13-
"test": "vitest run tests/*",
14-
"test:watch": "vitest --watch tests/*",
13+
"test": "TZ=UTC vitest run tests/*",
14+
"test:watch": "TZ=UTC vitest --watch tests/*",
1515
"version": "auto-changelog -p && git add CHANGELOG.md",
16-
"coverage": "vitest run --coverage"
16+
"coverage": "TZ=UTC vitest run --coverage"
1717
},
1818
"engines": {
1919
"node": ">=18.0.0"

tests/utils.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ describe('formatDate', () => {
1515
});
1616

1717
it('should handle different date and time', () => {
18-
const dateString = '2023-01-01T00:00:00.000Z';
19-
const expected = '01/01/2023, 24:00:00';
18+
const dateString = '2023-01-01T00:30:05.000Z';
19+
const dateObject = new Date(Date.UTC(2023, 0, 0, 24, 30, 5));
20+
const expected = '01/01/2023, 24:30:05';
2021
expect(formatDate(dateString)).toBe(expected);
22+
expect(formatDate(dateObject)).toBe(expected);
23+
});
24+
25+
it('should handle invalid date', () => {
26+
const dateString = 'invalid-date';
27+
expect(formatDate(dateString)).toBe('Invalid Date');
2128
});
22-
it('should handle invalid date', () => {
23-
const dateString = 'invalid-date';
24-
expect(formatDate(dateString)).toBe('Invalid Date');
25-
});
2629
});
2730

2831
describe('formatDateTime', () => {

0 commit comments

Comments
 (0)