fix: milliseconds test and e2e
This commit is contained in:
		
							parent
							
								
									6fd79d6e06
								
							
						
					
					
						commit
						3ef7e50b5b
					
				| @ -11,7 +11,7 @@ test.describe('Date time converter - json to yaml', () => { | |||||||
| 
 | 
 | ||||||
|   test('Format is auto detected from a date and the date is correctly converted', async ({ page }) => { |   test('Format is auto detected from a date and the date is correctly converted', async ({ page }) => { | ||||||
|     const initialFormat = await page.getByTestId('date-time-converter-format-select').innerText(); |     const initialFormat = await page.getByTestId('date-time-converter-format-select').innerText(); | ||||||
|     expect(initialFormat.trim()).toEqual('Timestamp'); |     expect(initialFormat.trim()).toEqual('Unix timestamp'); | ||||||
| 
 | 
 | ||||||
|     await page.getByTestId('date-time-converter-input').fill('2023-04-12T23:10:24+02:00'); |     await page.getByTestId('date-time-converter-input').fill('2023-04-12T23:10:24+02:00'); | ||||||
| 
 | 
 | ||||||
| @ -22,6 +22,7 @@ test.describe('Date time converter - json to yaml', () => { | |||||||
|       'Wed Apr 12 2023 23:10:24 GMT+0200 (Central European Summer Time)', |       'Wed Apr 12 2023 23:10:24 GMT+0200 (Central European Summer Time)', | ||||||
|     ); |     ); | ||||||
|     expect((await page.getByTestId('ISO 8601').inputValue()).trim()).toEqual('2023-04-12T23:10:24+02:00'); |     expect((await page.getByTestId('ISO 8601').inputValue()).trim()).toEqual('2023-04-12T23:10:24+02:00'); | ||||||
|  |     expect((await page.getByTestId('ISO 8601 UTC').inputValue()).trim()).toEqual('2023-04-12T21:10:24.000Z'); | ||||||
|     expect((await page.getByTestId('ISO 9075').inputValue()).trim()).toEqual('2023-04-12 23:10:24'); |     expect((await page.getByTestId('ISO 9075').inputValue()).trim()).toEqual('2023-04-12 23:10:24'); | ||||||
|     expect((await page.getByTestId('Unix timestamp').inputValue()).trim()).toEqual('1681333824'); |     expect((await page.getByTestId('Unix timestamp').inputValue()).trim()).toEqual('1681333824'); | ||||||
|     expect((await page.getByTestId('RFC 7231').inputValue()).trim()).toEqual('Wed, 12 Apr 2023 21:10:24 GMT'); |     expect((await page.getByTestId('RFC 7231').inputValue()).trim()).toEqual('Wed, 12 Apr 2023 21:10:24 GMT'); | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ import { | |||||||
|   isRFC3339DateString, |   isRFC3339DateString, | ||||||
|   isRFC7231DateString, |   isRFC7231DateString, | ||||||
|   isTimestamp, |   isTimestamp, | ||||||
|  |   isTimestampMicroSeconds, | ||||||
|   isUTCDateString, |   isUTCDateString, | ||||||
|   isUnixTimestamp, |   isUnixTimestamp, | ||||||
|   toJSDate, |   toJSDate, | ||||||
| @ -130,19 +131,18 @@ describe('date-time-converter models', () => { | |||||||
| 
 | 
 | ||||||
|   describe('isTimestampMicroSeconds', () => { |   describe('isTimestampMicroSeconds', () => { | ||||||
|     test('should return true for valid Unix timestamps in microseconds', () => { |     test('should return true for valid Unix timestamps in microseconds', () => { | ||||||
|       expect(isTimestamp('1649792026123123')).toBe(true); |       expect(isTimestampMicroSeconds('1649792026123123')).toBe(true); | ||||||
|       expect(isTimestamp('1701227351995845')).toBe(true); |       expect(isTimestampMicroSeconds('1701227351995845')).toBe(true); | ||||||
|       expect(isTimestamp('0')).toBe(true); |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     test('should return false for invalid Unix timestamps in microseconds', () => { |     test('should return false for invalid Unix timestamps in microseconds', () => { | ||||||
|       expect(isTimestamp('foo')).toBe(false); |       expect(isTimestampMicroSeconds('foo')).toBe(false); | ||||||
|       expect(isTimestamp('')).toBe(false); |       expect(isTimestampMicroSeconds('')).toBe(false); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     test('should return false for invalid Unix timestamps not in microseconds', () => { |     test('should return false for invalid Unix timestamps not in microseconds', () => { | ||||||
|       expect(isTimestamp('170122735199584')).toBe(false); |       expect(isTimestampMicroSeconds('170122735199584')).toBe(false); | ||||||
|       expect(isTimestamp('17012273519958')).toBe(false); |       expect(isTimestampMicroSeconds('17012273519958')).toBe(false); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user