|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const chai = require('chai'); |
| 4 | +const expect = chai.expect; |
| 5 | +const path = require('path'); |
| 6 | + |
| 7 | +const resolve = require('../index').resolve; |
| 8 | + |
| 9 | +const file = path.join(__dirname, 'files', 'src', 'jsx', 'dummy.js'); |
| 10 | + |
| 11 | +describe('cache', function () { |
| 12 | + it('can distinguish different config files', function () { |
| 13 | + const setting1 = { |
| 14 | + config: require(path.join(__dirname, './files/webpack.function.config.js')), |
| 15 | + argv: { |
| 16 | + mode: 'test', |
| 17 | + }, |
| 18 | + cache: true, |
| 19 | + }; |
| 20 | + expect(resolve('baz', file, setting1)).to.have.property('path') |
| 21 | + .and.equal(path.join(__dirname, 'files', 'some', 'bar', 'bar.js')); |
| 22 | + const setting2 = { |
| 23 | + config: require(path.join(__dirname, './files/webpack.function.config.multiple.js')), |
| 24 | + cache: true, |
| 25 | + }; |
| 26 | + expect(resolve('baz', file, setting2)).to.have.property('path') |
| 27 | + .and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js')); |
| 28 | + }); |
| 29 | + |
| 30 | + it('can distinguish different config', function () { |
| 31 | + const setting1 = { |
| 32 | + config: require(path.join(__dirname, './files/webpack.function.config.js')), |
| 33 | + env: { |
| 34 | + dummy: true, |
| 35 | + }, |
| 36 | + cache: true, |
| 37 | + }; |
| 38 | + expect(resolve('bar', file, setting1)).to.have.property('path') |
| 39 | + .and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'bar.js')); |
| 40 | + const setting2 = { |
| 41 | + config: require(path.join(__dirname, './files/webpack.function.config.multiple.js')), |
| 42 | + cache: true, |
| 43 | + }; |
| 44 | + const result = resolve('bar', file, setting2); |
| 45 | + expect(result).not.to.have.property('path'); |
| 46 | + expect(result).to.have.property('found').to.be.false; |
| 47 | + }); |
| 48 | +}); |
0 commit comments