| 
									
										
										
										
											2018-12-27 18:21:26 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const webpack = require(".."); | 
					
						
							| 
									
										
										
										
											2020-02-13 00:13:53 +08:00
										 |  |  | const { createFsFromVolume, Volume } = require("memfs"); | 
					
						
							| 
									
										
										
										
											2018-12-27 18:21:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe("MultiStats", () => { | 
					
						
							|  |  |  | 	it("should create JSON of children stats", done => { | 
					
						
							| 
									
										
										
										
											2019-02-19 15:58:46 +08:00
										 |  |  | 		const compiler = webpack([ | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				context: __dirname, | 
					
						
							|  |  |  | 				entry: "./fixtures/a" | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				context: __dirname, | 
					
						
							|  |  |  | 				entry: "./fixtures/b" | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		]); | 
					
						
							| 
									
										
										
										
											2020-02-15 13:54:52 +08:00
										 |  |  | 		compiler.outputFileSystem = createFsFromVolume(new Volume()); | 
					
						
							| 
									
										
										
										
											2018-12-27 18:21:26 +08:00
										 |  |  | 		compiler.run((err, stats) => { | 
					
						
							|  |  |  | 			if (err) return done(err); | 
					
						
							|  |  |  | 			try { | 
					
						
							|  |  |  | 				const statsObject = stats.toJson(); | 
					
						
							| 
									
										
										
										
											2019-02-19 15:58:46 +08:00
										 |  |  | 				expect(statsObject).toEqual( | 
					
						
							|  |  |  | 					expect.objectContaining({ children: expect.any(Array) }) | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-12-27 18:21:26 +08:00
										 |  |  | 				expect(statsObject.children).toHaveLength(2); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			} catch (e) { | 
					
						
							|  |  |  | 				done(e); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); |