| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | const path = require("path"); | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | const util = require("util"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const WebpackError = require("../lib/WebpackError"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe("WebpackError", () => { | 
					
						
							|  |  |  | 	class CustomError extends WebpackError { | 
					
						
							|  |  |  | 		constructor(message) { | 
					
						
							|  |  |  | 			super(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.name = "CustomError"; | 
					
						
							|  |  |  | 			this.message = "CustomMessage"; | 
					
						
							|  |  |  | 			this.details = "CustomDetails"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Error.captureStackTrace(this, this.constructor); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 	it("Should provide inspect method for use by for util.inspect", () => { | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | 		const errorStr = util.inspect(new CustomError("Message")); | 
					
						
							|  |  |  | 		const errorArr = errorStr.split("\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 		expect(errorArr[0]).toBe("CustomError: CustomMessage"); | 
					
						
							|  |  |  | 		expect(errorArr[1]).toMatch(path.basename(__filename)); | 
					
						
							|  |  |  | 		expect(errorArr[errorArr.length - 1]).toBe("CustomDetails"); | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | }); |