mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +00:00 
			
		
		
		
	 f95117f75d
			
		
	
	
		f95117f75d
		
	
	
	
	
		
			
			Update to the latest version of the spec which was refactored to use time zone methods record. This requires updating a whole bunch of callers to pass through a record too. This also ends up improving exceptions on a missing getOffsetNanosecondsFor method.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| describe("correct behavior", () => {
 | |
|     test("length is 0", () => {
 | |
|         expect(Temporal.Now.plainTimeISO).toHaveLength(0);
 | |
|     });
 | |
| 
 | |
|     test("basic functionality", () => {
 | |
|         const plainTime = Temporal.Now.plainTimeISO();
 | |
|         expect(plainTime).toBeInstanceOf(Temporal.PlainTime);
 | |
|         expect(plainTime.calendar.id).toBe("iso8601");
 | |
|     });
 | |
| 
 | |
|     test("custom time zone", () => {
 | |
|         const timeZone = {
 | |
|             getOffsetNanosecondsFor() {
 | |
|                 return 86399999999999;
 | |
|             },
 | |
|         };
 | |
|         const plainTime = Temporal.Now.plainTimeISO("UTC");
 | |
|         const plainTimeWithOffset = Temporal.Now.plainTimeISO(timeZone);
 | |
|         // FIXME: Compare these in a sensible way
 | |
|     });
 | |
| 
 | |
|     test("cannot have a time zone with more than a day", () => {
 | |
|         [86400000000000, -86400000000000, 86400000000001, 86400000000002].forEach(offset => {
 | |
|             const timeZone = {
 | |
|                 getOffsetNanosecondsFor() {
 | |
|                     return offset;
 | |
|                 },
 | |
|             };
 | |
|             expect(() => Temporal.Now.plainTimeISO(timeZone)).toThrowWithMessage(
 | |
|                 RangeError,
 | |
|                 "Invalid offset nanoseconds value, must be in range -86400 * 10^9 + 1 to 86400 * 10^9 - 1"
 | |
|             );
 | |
|         });
 | |
|     });
 | |
| });
 | |
| 
 | |
| describe("errors", () => {
 | |
|     test("custom time zone doesn't have a getOffsetNanosecondsFor function", () => {
 | |
|         expect(() => {
 | |
|             Temporal.Now.plainTimeISO({});
 | |
|         }).toThrowWithMessage(TypeError, "getOffsetNanosecondsFor is undefined");
 | |
|     });
 | |
| });
 |