| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | test("length is 2", () => { | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   expect(Reflect.has).toHaveLength(2); | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | describe("errors", () => { | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   test("target must be an object", () => { | 
					
						
							|  |  |  |     [null, undefined, "foo", 123, NaN, Infinity].forEach(value => { | 
					
						
							|  |  |  |       expect(() => { | 
					
						
							|  |  |  |         Reflect.has(value); | 
					
						
							|  |  |  |       }).toThrowWithMessage(TypeError, "First argument of Reflect.has() must be an object"); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | describe("normal behavior", () => { | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   test("regular object has property", () => { | 
					
						
							|  |  |  |     expect(Reflect.has({})).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has({ undefined })).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has({ 0: "1" }, "0")).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has({ foo: "bar" }, "foo")).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has({ bar: "baz" }, "foo")).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has({}, "toString")).toBeTrue(); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   test("array has property", () => { | 
					
						
							|  |  |  |     expect(Reflect.has([])).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has([], 0)).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has([1, 2, 3], "0")).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has([1, 2, 3], 0)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has([1, 2, 3], 1)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has([1, 2, 3], 2)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has([1, 2, 3], 3)).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has([], "pop")).toBeTrue(); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   test("string object has property", () => { | 
					
						
							|  |  |  |     expect(Reflect.has(new String())).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), "0")).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), 0)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), 1)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), 2)).toBeTrue(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), 3)).toBeFalse(); | 
					
						
							|  |  |  |     expect(Reflect.has(new String("foo"), "charAt")).toBeTrue(); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | }); |