Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/eslint-plugin-import
Path: blob/main/resolvers/webpack/test/root.js
829 views
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
10
const file = path.join(__dirname, 'files', 'src', 'dummy.js');
11
const webpackDir = path.join(__dirname, 'different-package-location');
12
13
describe('root', function () {
14
it('works', function () {
15
expect(resolve('main-module', file)).property('path')
16
.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
17
});
18
it('really works', function () {
19
expect(resolve('jsx/some-file', file)).property('path')
20
.to.equal(path.join(__dirname, 'files', 'src', 'jsx', 'some-file.js'));
21
});
22
it('supports definition as an array', function () {
23
expect(resolve('main-module', file, { config: 'webpack.array-root.config.js' }))
24
.property('path')
25
.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
26
expect(resolve('typeahead', file, { config: 'webpack.array-root.config.js' }))
27
.property('path')
28
.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));
29
});
30
it('supports definition as a function', function () {
31
expect(resolve('main-module', file, { config: 'webpack.function.config.js' }))
32
.property('path')
33
.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
34
expect(resolve('typeahead', file, { config: 'webpack.function.config.js' }))
35
.property('path')
36
.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));
37
});
38
it('supports passing a different directory to load webpack from', function () {
39
// Webpack should still be able to resolve the config here
40
expect(resolve('main-module', file, { config: 'webpack.config.js', cwd: webpackDir }))
41
.property('path')
42
.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));
43
expect(resolve('typeahead', file, { config: 'webpack.config.js', cwd: webpackDir }))
44
.property('path')
45
.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));
46
});
47
});
48
49