| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | /* globals describe, it, beforeEach */ | 
					
						
							|  |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | const DelegatedModule = require("../lib/DelegatedModule"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | describe("DelegatedModule", () => { | 
					
						
							|  |  |  | 	describe("#updateHash", () => { | 
					
						
							| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | 		const sourceRequest = "dll-reference dll_e54c0fb67f8152792ad2"; | 
					
						
							|  |  |  | 		const data = { | 
					
						
							|  |  |  | 			id: "/xg9" | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 		const type = "require"; | 
					
						
							|  |  |  | 		const userRequest = "./library.js"; | 
					
						
							|  |  |  | 		let hashedText; | 
					
						
							|  |  |  | 		let hash; | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 		beforeEach(() => { | 
					
						
							| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | 			hashedText = ""; | 
					
						
							|  |  |  | 			hash = { | 
					
						
							|  |  |  | 				update: (text) => { | 
					
						
							|  |  |  | 					hashedText += text; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 			const delegatedModule = new DelegatedModule(sourceRequest, data, type, userRequest); | 
					
						
							|  |  |  | 			delegatedModule.updateHash(hash); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 		it("updates hash with delegated module ID", () => { | 
					
						
							|  |  |  | 			expect(hashedText).toMatch("/xg9"); | 
					
						
							| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 		it("updates hash with delegation type", () => { | 
					
						
							|  |  |  | 			expect(hashedText).toMatch("require"); | 
					
						
							| 
									
										
										
										
											2017-09-18 00:19:22 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-09-16 04:16:12 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | }); |