Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/eslint-plugin-import
Path: blob/main/resolvers/webpack/test/alias.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 webpack = require('../index');
8
9
const file = path.join(__dirname, 'files', 'dummy.js');
10
11
describe('resolve.alias', function () {
12
let resolved;
13
before(function () { resolved = webpack.resolve('foo', file); });
14
15
it('is found', function () { expect(resolved).to.have.property('found', true); });
16
17
it('is correct', function () {
18
expect(resolved).to.have.property('path')
19
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js'));
20
});
21
});
22
23
// todo: reimplement with resolver function / config
24
// describe.skip('webpack alias spec', function () {
25
// // from table: https://webpack.github.io/docs/configuration.html#resolve-alias
26
// function tableLine(alias, xyz, xyzFile) {
27
// describe(JSON.stringify(alias), function () {
28
// it('xyz: ' + xyz, function () {
29
// expect(resolveAlias('xyz', alias)).to.equal(xyz);
30
// });
31
// it('xyz/file: ' + (xyzFile.name || xyzFile), function () {
32
// if (xyzFile === Error) {
33
// expect(resolveAlias.bind(null, 'xyz/file', alias)).to.throw(xyzFile);
34
// } else {
35
// expect(resolveAlias('xyz/file', alias)).to.equal(xyzFile);
36
// }
37
// });
38
// });
39
// }
40
41
// tableLine( {}
42
// , 'xyz', 'xyz/file' );
43
44
// tableLine( { xyz: '/absolute/path/to/file.js' }
45
// , '/absolute/path/to/file.js', 'xyz/file' );
46
47
// tableLine( { xyz$: '/absolute/path/to/file.js' }
48
// , '/absolute/path/to/file.js', Error );
49
50
// tableLine( { xyz: './dir/file.js' }
51
// , './dir/file.js', 'xyz/file' );
52
53
// tableLine( { xyz$: './dir/file.js' }
54
// , './dir/file.js', Error );
55
56
// tableLine( { xyz: '/some/dir' }
57
// , '/some/dir', '/some/dir/file' );
58
59
// tableLine( { xyz$: '/some/dir' }
60
// , '/some/dir', 'xyz/file' );
61
62
// tableLine( { xyz: './dir' }
63
// , './dir', './dir/file' );
64
65
// tableLine( { xyz: 'modu' }
66
// , 'modu', 'modu/file' );
67
68
// tableLine( { xyz$: 'modu' }
69
// , 'modu', 'xyz/file' );
70
71
// tableLine( { xyz: 'modu/some/file.js' }
72
// , 'modu/some/file.js', Error );
73
74
// tableLine( { xyz: 'modu/dir' }
75
// , 'modu/dir', 'modu/dir/file' );
76
77
// tableLine( { xyz: 'xyz/dir' }
78
// , 'xyz/dir', 'xyz/dir/file' );
79
80
// tableLine( { xyz$: 'xyz/dir' }
81
// , 'xyz/dir', 'xyz/file' );
82
// });
83
84
// describe.skip('nested module names', function () {
85
// // from table: https://webpack.github.io/docs/configuration.html#resolve-alias
86
// function nestedName(alias, xyz, xyzFile) {
87
// describe(JSON.stringify(alias), function () {
88
// it('top/xyz: ' + xyz, function () {
89
// expect(resolveAlias('top/xyz', alias)).to.equal(xyz);
90
// });
91
// it('top/xyz/file: ' + (xyzFile.name || xyzFile), function () {
92
// if (xyzFile === Error) {
93
// expect(resolveAlias.bind(null, 'top/xyz/file', alias)).to.throw(xyzFile);
94
// } else {
95
// expect(resolveAlias('top/xyz/file', alias)).to.equal(xyzFile);
96
// }
97
// });
98
// });
99
// }
100
101
// nestedName( { 'top/xyz': '/absolute/path/to/file.js' }
102
// , '/absolute/path/to/file.js', 'top/xyz/file' );
103
104
// nestedName( { 'top/xyz$': '/absolute/path/to/file.js' }
105
// , '/absolute/path/to/file.js', Error );
106
107
// nestedName( { 'top/xyz': './dir/file.js' }
108
// , './dir/file.js', 'top/xyz/file' );
109
110
// nestedName( { 'top/xyz$': './dir/file.js' }
111
// , './dir/file.js', Error );
112
113
// nestedName( { 'top/xyz': '/some/dir' }
114
// , '/some/dir', '/some/dir/file' );
115
116
// nestedName( { 'top/xyz$': '/some/dir' }
117
// , '/some/dir', 'top/xyz/file' );
118
119
// nestedName( { 'top/xyz': './dir' }
120
// , './dir', './dir/file' );
121
122
// nestedName( { 'top/xyz': 'modu' }
123
// , 'modu', 'modu/file' );
124
125
// nestedName( { 'top/xyz$': 'modu' }
126
// , 'modu', 'top/xyz/file' );
127
128
// nestedName( { 'top/xyz': 'modu/some/file.js' }
129
// , 'modu/some/file.js', Error );
130
131
// nestedName( { 'top/xyz': 'modu/dir' }
132
// , 'modu/dir', 'modu/dir/file' );
133
134
// nestedName( { 'top/xyz': 'top/xyz/dir' }
135
// , 'top/xyz/dir', 'top/xyz/dir/file' );
136
137
// nestedName( { 'top/xyz$': 'top/xyz/dir' }
138
// , 'top/xyz/dir', 'top/xyz/file' );
139
// });
140
141