Skip to content

Commit 0c18e40

Browse files
committed
[Tests] add some tests for a non-directory basedir
Related to #154.
1 parent 1de53b2 commit 0c18e40

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

test/resolver.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,16 @@ test('async dot slash main', function (t) {
347347
t.end();
348348
});
349349
});
350+
351+
test('not a directory', function (t) {
352+
t.plan(5);
353+
var path = './foo';
354+
resolve(path, { basedir: __filename }, function (err, res, pkg) {
355+
t.ok(err, 'a non-directory errors');
356+
t.equal(arguments.length, 1);
357+
t.equal(res, undefined);
358+
t.equal(pkg, undefined);
359+
360+
t.equal(err && err.message, 'Cannot find module \'' + path + "' from '" + __filename + "'");
361+
});
362+
});

test/resolver_sync.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,15 @@ test('sync dot slash main', function (t) {
265265
t.ok(new Date() - start < 50, 'resolve.sync timedout');
266266
t.end();
267267
});
268+
269+
test('not a directory', function (t) {
270+
var path = './foo';
271+
try {
272+
resolve.sync(path, { basedir: __filename });
273+
t.fail();
274+
} catch (err) {
275+
t.ok(err, 'a non-directory errors');
276+
t.equal(err && err.message, 'Cannot find module \'' + path + "' from '" + __filename + "'");
277+
}
278+
t.end();
279+
});

0 commit comments

Comments
 (0)