|
| 1 | +var should = require("should"); |
| 2 | +var CaseSensitiveModulesWarning = require("../lib/CaseSensitiveModulesWarning"); |
| 3 | + |
| 4 | +var createModule = function(identifier, numberOfReasons) { |
| 5 | + var reasons = new Array(numberOfReasons || 0).fill(null).map(function(value, index) { |
| 6 | + return { |
| 7 | + module: createModule(`${identifier}-reason-${index}`) |
| 8 | + }; |
| 9 | + }); |
| 10 | + |
| 11 | + return { |
| 12 | + identifier: () => identifier, |
| 13 | + reasons |
| 14 | + }; |
| 15 | +}; |
| 16 | + |
| 17 | +describe("CaseSensitiveModulesWarning", function() { |
| 18 | + var myCaseSensitiveModulesWarning, modules; |
| 19 | + |
| 20 | + beforeEach(function() { |
| 21 | + modules = [ |
| 22 | + createModule('FooBar', 1), |
| 23 | + createModule('foobar', 2), |
| 24 | + createModule('FOOBAR') |
| 25 | + ]; |
| 26 | + myCaseSensitiveModulesWarning = new CaseSensitiveModulesWarning(modules); |
| 27 | + }); |
| 28 | + |
| 29 | + it('has the a name', function() { |
| 30 | + myCaseSensitiveModulesWarning.name.should.be.exactly('CaseSensitiveModulesWarning'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('has the a message', function() { |
| 34 | + myCaseSensitiveModulesWarning.message.should.be.exactly(` |
| 35 | +There are multiple modules with names that only differ in casing. |
| 36 | +This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. |
| 37 | +Use equal casing. Compare these module identifiers: |
| 38 | +* FOOBAR |
| 39 | +* FooBar |
| 40 | + Used by 1 module(s), i. e. |
| 41 | + FooBar-reason-0 |
| 42 | +* foobar |
| 43 | + Used by 2 module(s), i. e. |
| 44 | + foobar-reason-0 |
| 45 | +`.trim()); |
| 46 | + }); |
| 47 | + |
| 48 | + it('has the an origin', function() { |
| 49 | + myCaseSensitiveModulesWarning.origin.should.be.exactly(modules[0]); |
| 50 | + }); |
| 51 | + |
| 52 | + it('has the a module', function() { |
| 53 | + myCaseSensitiveModulesWarning.module.should.be.exactly(modules[0]); |
| 54 | + }); |
| 55 | +}); |
0 commit comments