| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const AbstractMethodError = require("../lib/AbstractMethodError"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe("WebpackError", () => { | 
					
						
							|  |  |  | 	class Foo { | 
					
						
							|  |  |  | 		abstractMethod() { | 
					
						
							|  |  |  | 			return new AbstractMethodError(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	class Child extends Foo {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 22:19:51 +08:00
										 |  |  | 	const expectedMessage = "Abstract method $1. Must be overridden."; | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 	it("should construct message with caller info", () => { | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | 		const fooClassError = new Foo().abstractMethod(); | 
					
						
							|  |  |  | 		const childClassError = new Child().abstractMethod(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		expect(fooClassError.message).toBe( | 
					
						
							|  |  |  | 			expectedMessage.replace("$1", "Foo.abstractMethod") | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		expect(childClassError.message).toBe( | 
					
						
							|  |  |  | 			expectedMessage.replace("$1", "Child.abstractMethod") | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); |