This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -172,6 +172,21 @@ test('other path', function (t) {
t.end();
});
test('path iterator', function (t) {
var resolverDir = path.join(__dirname, 'resolver');
var exactIterator = function (x, start, getPackageCandidates, opts) {
return [path.join(resolverDir, x)];
};
t.equal(
resolve.sync('baz', { packageIterator: exactIterator }),
path.join(resolverDir, 'baz/quux.js')
);
t.end();
});
test('incorrect main', function (t) {
var resolverDir = path.join(__dirname, 'resolver');
var dir = path.join(resolverDir, 'incorrect_main');
@@ -223,6 +238,20 @@ test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is
t.end();
});
test('#211 - incorrectly resolves module-paths like "." when from inside a folder with a sibling file of the same name', function (t) {
var dir = path.join(__dirname, 'resolver');
t.equal(
resolve.sync('./', { basedir: path.join(dir, 'same_names/foo') }),
path.join(dir, 'same_names/foo/index.js')
);
t.equal(
resolve.sync('.', { basedir: path.join(dir, 'same_names/foo') }),
path.join(dir, 'same_names/foo/index.js')
);
t.end();
});
test('sync: #121 - treating an existing file as a dir when no basedir', function (t) {
var testFile = path.basename(__filename);
@@ -318,8 +347,8 @@ test('browser field in package.json', function (t) {
basedir: dir,
packageFilter: function packageFilter(pkg) {
if (pkg.browser) {
pkg.main = pkg.browser;
delete pkg.browser;
pkg.main = pkg.browser; // eslint-disable-line no-param-reassign
delete pkg.browser; // eslint-disable-line no-param-reassign
}
return pkg;
}