| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | test("basic functionality", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(function () {}.name).toBe(""); | 
					
						
							| 
									
										
										
										
											2020-05-02 19:18:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     function bar() {} | 
					
						
							|  |  |  |     expect(bar.name).toBe("bar"); | 
					
						
							|  |  |  |     expect((bar.name = "baz")).toBe("baz"); | 
					
						
							|  |  |  |     expect(bar.name).toBe("bar"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("function assigned to variable", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     let foo = function () {}; | 
					
						
							|  |  |  |     expect(foo.name).toBe("foo"); | 
					
						
							|  |  |  |     expect((foo.name = "bar")).toBe("bar"); | 
					
						
							|  |  |  |     expect(foo.name).toBe("foo"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let a, b; | 
					
						
							|  |  |  |     a = b = function () {}; | 
					
						
							|  |  |  |     expect(a.name).toBe("b"); | 
					
						
							|  |  |  |     expect(b.name).toBe("b"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("functions in array assigned to variable", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     const arr = [function () {}, function () {}, function () {}]; | 
					
						
							|  |  |  |     expect(arr[0].name).toBe("arr"); | 
					
						
							|  |  |  |     expect(arr[1].name).toBe("arr"); | 
					
						
							|  |  |  |     expect(arr[2].name).toBe("arr"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("functions in objects", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     let f; | 
					
						
							|  |  |  |     let o = { a: function () {} }; | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(o.a.name).toBe("a"); | 
					
						
							|  |  |  |     f = o.a; | 
					
						
							|  |  |  |     expect(f.name).toBe("a"); | 
					
						
							|  |  |  |     expect(o.a.name).toBe("a"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     o = { ...o, b: f }; | 
					
						
							|  |  |  |     expect(o.a.name).toBe("a"); | 
					
						
							|  |  |  |     expect(o.b.name).toBe("a"); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     o.c = function () {}; | 
					
						
							|  |  |  |     expect(o.c.name).toBe("c"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("names of native functions", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(console.debug.name).toBe("debug"); | 
					
						
							|  |  |  |     expect((console.debug.name = "warn")).toBe("warn"); | 
					
						
							|  |  |  |     expect(console.debug.name).toBe("debug"); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); |