| 
									
										
										
										
											2017-01-19 02:28:57 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | const CaseSensitiveModulesWarning = require("../lib/CaseSensitiveModulesWarning"); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | const createModule = function(identifier, numberOfReasons) { | 
					
						
							| 
									
										
										
										
											2018-02-25 18:46:17 +08:00
										 |  |  | 	const reasons = new Array(numberOfReasons || 0) | 
					
						
							|  |  |  | 		.fill(null) | 
					
						
							|  |  |  | 		.map((value, index) => { | 
					
						
							|  |  |  | 			return { | 
					
						
							|  |  |  | 				module: createModule(`${identifier}-reason-${index}`) | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return { | 
					
						
							|  |  |  | 		identifier: () => identifier, | 
					
						
							|  |  |  | 		reasons | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | describe("CaseSensitiveModulesWarning", () => { | 
					
						
							|  |  |  | 	let myCaseSensitiveModulesWarning; | 
					
						
							|  |  |  | 	let modules; | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | 	beforeEach(() => { | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 		modules = [ | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | 			createModule("FOOBAR"), | 
					
						
							|  |  |  | 			createModule("FooBar", 1), | 
					
						
							|  |  |  | 			createModule("foobar", 2) | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 		]; | 
					
						
							|  |  |  | 		myCaseSensitiveModulesWarning = new CaseSensitiveModulesWarning(modules); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 	it("has the a name", () => { | 
					
						
							| 
									
										
										
										
											2018-02-25 18:46:17 +08:00
										 |  |  | 		expect(myCaseSensitiveModulesWarning.name).toBe( | 
					
						
							|  |  |  | 			"CaseSensitiveModulesWarning" | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-17 23:03:39 +08:00
										 |  |  | 	it("has the a message", () => { | 
					
						
							| 
									
										
										
										
											2018-02-25 18:46:17 +08:00
										 |  |  | 		expect(myCaseSensitiveModulesWarning.message).toBe( | 
					
						
							|  |  |  | 			`
 | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | There are multiple modules with names that only differ in casing. | 
					
						
							|  |  |  | This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. | 
					
						
							|  |  |  | Use equal casing. Compare these module identifiers: | 
					
						
							|  |  |  | * FOOBAR | 
					
						
							|  |  |  | * FooBar | 
					
						
							|  |  |  |     Used by 1 module(s), i. e. | 
					
						
							|  |  |  |     FooBar-reason-0 | 
					
						
							|  |  |  | * foobar | 
					
						
							|  |  |  |     Used by 2 module(s), i. e. | 
					
						
							|  |  |  |     foobar-reason-0 | 
					
						
							| 
									
										
										
										
											2018-02-25 18:46:17 +08:00
										 |  |  | `.trim()
 | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 	it("has the an origin", () => { | 
					
						
							|  |  |  | 		expect(myCaseSensitiveModulesWarning.origin).toBe(modules[0]); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 20:17:21 +08:00
										 |  |  | 	it("has the a module", () => { | 
					
						
							|  |  |  | 		expect(myCaseSensitiveModulesWarning.module).toBe(modules[0]); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-01-04 14:22:19 +08:00
										 |  |  | }); |