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