| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | test("length is 1", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(Reflect.ownKeys).toHaveLength(1); | 
					
						
							| 
									
										
										
										
											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-06 07:37:45 -07:00
										 |  |  |     test("target must be an object", () => { | 
					
						
							|  |  |  |         [null, undefined, "foo", 123, NaN, Infinity].forEach(value => { | 
					
						
							|  |  |  |             expect(() => { | 
					
						
							|  |  |  |                 Reflect.ownKeys(value); | 
					
						
							|  |  |  |             }).toThrowWithMessage( | 
					
						
							|  |  |  |                 TypeError, | 
					
						
							|  |  |  |                 "First argument of Reflect.ownKeys() must be an object" | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01: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-06 07:37:45 -07:00
										 |  |  |     test("regular empty object has no own keys", () => { | 
					
						
							|  |  |  |         var objectOwnKeys = Reflect.ownKeys({}); | 
					
						
							|  |  |  |         expect(objectOwnKeys instanceof Array).toBeTrue(); | 
					
						
							|  |  |  |         expect(objectOwnKeys).toHaveLength(0); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("regular object with some properties has own keys", () => { | 
					
						
							|  |  |  |         var objectOwnKeys = Reflect.ownKeys({ foo: "bar", bar: "baz", 0: 42 }); | 
					
						
							|  |  |  |         expect(objectOwnKeys instanceof Array).toBeTrue(); | 
					
						
							|  |  |  |         expect(objectOwnKeys).toHaveLength(3); | 
					
						
							|  |  |  |         expect(objectOwnKeys[0]).toBe("0"); | 
					
						
							|  |  |  |         expect(objectOwnKeys[1]).toBe("foo"); | 
					
						
							|  |  |  |         expect(objectOwnKeys[2]).toBe("bar"); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("empty array has only 'length' own key", () => { | 
					
						
							|  |  |  |         var arrayOwnKeys = Reflect.ownKeys([]); | 
					
						
							|  |  |  |         expect(arrayOwnKeys instanceof Array).toBeTrue(); | 
					
						
							|  |  |  |         expect(arrayOwnKeys).toHaveLength(1); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[0]).toBe("length"); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:06:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("array with some values has 'lenght' and indices own keys", () => { | 
					
						
							|  |  |  |         var arrayOwnKeys = Reflect.ownKeys(["foo", [], 123, undefined]); | 
					
						
							|  |  |  |         expect(arrayOwnKeys instanceof Array).toBeTrue(); | 
					
						
							|  |  |  |         expect(arrayOwnKeys).toHaveLength(5); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[0]).toBe("0"); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[1]).toBe("1"); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[2]).toBe("2"); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[3]).toBe("3"); | 
					
						
							|  |  |  |         expect(arrayOwnKeys[4]).toBe("length"); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-04 15:42:19 +01:00
										 |  |  | }); |