mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:22:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			126 lines
		
	
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			126 lines
		
	
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="./include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         let testCounter = 1;
 | |
|         function testPart(part) {
 | |
|             try {
 | |
|                 println(`${testCounter}. ${JSON.stringify(part())}`);
 | |
|             } catch (e) {
 | |
|                 println(`${testCounter}. Exception: ${e.name}`);
 | |
|             }
 | |
|             testCounter++;
 | |
|         }
 | |
| 
 | |
|         // 1. Input date get value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.value = '2023-12-11';
 | |
|             return input.valueAsDate;
 | |
|         });
 | |
| 
 | |
|         // 2. Input date invalid get value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.value = 'invalid';
 | |
|             return input.valueAsDate;
 | |
|         });
 | |
| 
 | |
|         // 3. Input time get value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.value = '19:46';
 | |
|             return input.valueAsDate;
 | |
|         });
 | |
| 
 | |
|         // 4. Input time get value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.value = '19:46:19';
 | |
|             return input.valueAsDate;
 | |
|         });
 | |
| 
 | |
|         // 5. Input time invalid get value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.value = 'invalid';
 | |
|             return input.valueAsDate;
 | |
|         });
 | |
| 
 | |
|         // 6. Input date set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.valueAsDate = new Date(0);
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 7. Input date set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.valueAsDate = new Date(1702320457860);
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 8. Input date invalid set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.valueAsDate = {};
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 9. Input date null set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'date';
 | |
|             input.valueAsDate = null;
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 10. Input time set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.valueAsDate = new Date(1702320457000);
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 11. Input time set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.valueAsDate = new Date(1702320457100);
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 12. Input time set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.valueAsDate = new Date(1702320457864.5);
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 13. Input time invalid set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.valueAsDate = {};
 | |
|             return input.value;
 | |
|         });
 | |
| 
 | |
|         // 14. Input time null set value as date
 | |
|         testPart(() => {
 | |
|             const input = document.createElement('input');
 | |
|             input.type = 'time';
 | |
|             input.valueAsDate = null;
 | |
|             return input.value;
 | |
|         });
 | |
|     });
 | |
| </script>
 | 
