Skip to content

Commit 3ef7e50

Browse files
committed
fix: milliseconds test and e2e
1 parent 6fd79d6 commit 3ef7e50

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/tools/date-time-converter/date-time-converter.e2e.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.describe('Date time converter - json to yaml', () => {
1111

1212
test('Format is auto detected from a date and the date is correctly converted', async ({ page }) => {
1313
const initialFormat = await page.getByTestId('date-time-converter-format-select').innerText();
14-
expect(initialFormat.trim()).toEqual('Timestamp');
14+
expect(initialFormat.trim()).toEqual('Unix timestamp');
1515

1616
await page.getByTestId('date-time-converter-input').fill('2023-04-12T23:10:24+02:00');
1717

@@ -22,6 +22,7 @@ test.describe('Date time converter - json to yaml', () => {
2222
'Wed Apr 12 2023 23:10:24 GMT+0200 (Central European Summer Time)',
2323
);
2424
expect((await page.getByTestId('ISO 8601').inputValue()).trim()).toEqual('2023-04-12T23:10:24+02:00');
25+
expect((await page.getByTestId('ISO 8601 UTC').inputValue()).trim()).toEqual('2023-04-12T21:10:24.000Z');
2526
expect((await page.getByTestId('ISO 9075').inputValue()).trim()).toEqual('2023-04-12 23:10:24');
2627
expect((await page.getByTestId('Unix timestamp').inputValue()).trim()).toEqual('1681333824');
2728
expect((await page.getByTestId('RFC 7231').inputValue()).trim()).toEqual('Wed, 12 Apr 2023 21:10:24 GMT');

src/tools/date-time-converter/date-time-converter.models.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
isRFC3339DateString,
1313
isRFC7231DateString,
1414
isTimestamp,
15+
isTimestampMicroSeconds,
1516
isUTCDateString,
1617
isUnixTimestamp,
1718
toJSDate,
@@ -130,19 +131,18 @@ describe('date-time-converter models', () => {
130131

131132
describe('isTimestampMicroSeconds', () => {
132133
test('should return true for valid Unix timestamps in microseconds', () => {
133-
expect(isTimestamp('1649792026123123')).toBe(true);
134-
expect(isTimestamp('1701227351995845')).toBe(true);
135-
expect(isTimestamp('0')).toBe(true);
134+
expect(isTimestampMicroSeconds('1649792026123123')).toBe(true);
135+
expect(isTimestampMicroSeconds('1701227351995845')).toBe(true);
136136
});
137137

138138
test('should return false for invalid Unix timestamps in microseconds', () => {
139-
expect(isTimestamp('foo')).toBe(false);
140-
expect(isTimestamp('')).toBe(false);
139+
expect(isTimestampMicroSeconds('foo')).toBe(false);
140+
expect(isTimestampMicroSeconds('')).toBe(false);
141141
});
142142

143143
test('should return false for invalid Unix timestamps not in microseconds', () => {
144-
expect(isTimestamp('170122735199584')).toBe(false);
145-
expect(isTimestamp('17012273519958')).toBe(false);
144+
expect(isTimestampMicroSeconds('170122735199584')).toBe(false);
145+
expect(isTimestampMicroSeconds('17012273519958')).toBe(false);
146146
});
147147
});
148148

0 commit comments

Comments
 (0)