| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("basic method shorthand", () => { | 
					
						
							| 
									
										
										
										
											2020-04-30 23:40:45 -07:00
										 |  |  |     const o = { | 
					
						
							|  |  |  |         foo: "bar", | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  |         getFoo() {  | 
					
						
							| 
									
										
										
										
											2020-04-30 23:40:45 -07:00
										 |  |  |             return this.foo; | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  |     }; | 
					
						
							|  |  |  |     expect(o.getFoo()).toBe("bar"); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("numeric literal method shorthand", () => { | 
					
						
							|  |  |  |     const o = { | 
					
						
							|  |  |  |         foo: "bar", | 
					
						
							|  |  |  |         12() {  | 
					
						
							|  |  |  |             return this.foo; | 
					
						
							| 
									
										
										
										
											2020-04-30 23:40:45 -07:00
										 |  |  |         }, | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  |     expect(o[12]()).toBe("bar"); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-30 23:40:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("string literal method shorthand", () => { | 
					
						
							|  |  |  |     const o = { | 
					
						
							|  |  |  |         foo: "bar", | 
					
						
							|  |  |  |         "hello friends"() {  | 
					
						
							|  |  |  |             return this.foo; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     expect(o["hello friends"]()).toBe("bar"); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-30 23:40:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("computed property method shorthand", () => { | 
					
						
							|  |  |  |     const o = { | 
					
						
							|  |  |  |         foo: "bar", | 
					
						
							|  |  |  |         [4 + 10]() {  | 
					
						
							|  |  |  |             return this.foo; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     expect(o[14]()).toBe("bar"); | 
					
						
							|  |  |  | }); |