mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-24 17:09:43 +00:00 
			
		
		
		
	And the simple Temporal.PlainDate.prototype getters, so that the constructed Temporal.PlainDate may actually be validated.
		
			
				
	
	
		
			53 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| describe("errors", () => {
 | |
|     test("called without new", () => {
 | |
|         expect(() => {
 | |
|             Temporal.PlainDate();
 | |
|         }).toThrowWithMessage(
 | |
|             TypeError,
 | |
|             "Temporal.PlainDate constructor must be called with 'new'"
 | |
|         );
 | |
|     });
 | |
| 
 | |
|     test("cannot pass Infinity", () => {
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, 0, Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(-Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, -Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, 0, -Infinity);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|     });
 | |
| 
 | |
|     test("cannot pass invalid ISO month/day", () => {
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, 0, 1);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|         expect(() => {
 | |
|             new Temporal.PlainDate(0, 1, 0);
 | |
|         }).toThrowWithMessage(RangeError, "Invalid plain date");
 | |
|     });
 | |
| });
 | |
| 
 | |
| describe("normal behavior", () => {
 | |
|     test("length is 3", () => {
 | |
|         expect(Temporal.PlainDate).toHaveLength(3);
 | |
|     });
 | |
| 
 | |
|     test("basic functionality", () => {
 | |
|         const plainDate = new Temporal.PlainDate(2021, 7, 19);
 | |
|         expect(typeof plainDate).toBe("object");
 | |
|         expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
 | |
|         expect(Object.getPrototypeOf(plainDate)).toBe(Temporal.PlainDate.prototype);
 | |
|     });
 | |
| });
 |