Skip to content

Commit 90826f5

Browse files
author
James Halliday
committed
move pathfilter test to its own file
1 parent 70b71e7 commit 90826f5

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

lib/async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports = function resolve (x, opts, cb) {
9191
});
9292
}
9393
else if (x === y) {
94-
return loadAsDirectory(x, pkg, cb);
94+
return loadAsDirectory(y, pkg, cb);
9595
}
9696
else {
9797
return load(exts, x);

test/pathfilter.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var test = require('tape');
2+
var resolve = require('../');
3+
4+
test('#62: deep module references and the pathFilter', function(t){
5+
t.plan(6);
6+
7+
var resolverDir = __dirname + '/resolver/deep_ref';
8+
var pathFilter = function(pkg, x, remainder){
9+
t.equal(pkg.version, "1.2.3");
10+
t.equal(x, resolverDir + '/node_modules/deep/ref');
11+
t.equal(remainder, "ref");
12+
return "alt";
13+
};
14+
15+
resolve('deep/ref', { basedir : resolverDir }, function (err, res, pkg) {
16+
if (err) t.fail(err);
17+
t.equal(pkg.version, "1.2.3");
18+
t.equal(res, resolverDir + '/node_modules/deep/ref.js');
19+
});
20+
21+
resolve('deep/ref', { basedir : resolverDir, pathFilter : pathFilter },
22+
function (err, res, pkg) {
23+
if (err) t.fail(err);
24+
t.equal(res, resolverDir + '/node_modules/deep/alt.js');
25+
});
26+
});

test/resolver.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -279,29 +279,3 @@ test('#25: node modules with the same name as node stdlib modules', function (t)
279279
t.equal(res, resolverDir + '/node_modules/punycode/index.js');
280280
});
281281
});
282-
283-
test('#62: deep module references and the pathFilter', function(t){
284-
t.plan(6);
285-
286-
var resolverDir = __dirname + '/resolver/deep_ref';
287-
var pathFilter = function(pkg, x, remainder){
288-
t.equal(pkg.version, "1.2.3");
289-
t.equal(x, resolverDir + '/node_modules/deep/ref');
290-
t.equal(remainder, "ref");
291-
return "alt";
292-
};
293-
294-
295-
resolve('deep/ref', { basedir : resolverDir }, function (err, res, pkg) {
296-
if (err) t.fail(err);
297-
t.equal(pkg.version, "1.2.3");
298-
t.equal(res, resolverDir + '/node_modules/deep/ref.js');
299-
});
300-
301-
resolve('deep/ref', { basedir : resolverDir, pathFilter : pathFilter }, function (err, res, pkg) {
302-
if (err) t.fail(err);
303-
t.equal(res, resolverDir + '/node_modules/deep/alt.js');
304-
});
305-
306-
307-
});

0 commit comments

Comments
 (0)