dotdot.js (763B)
1 var path = require('path'); 2 var test = require('tape'); 3 var resolve = require('../'); 4 5 test('dotdot', function (t) { 6 t.plan(4); 7 var dir = __dirname + '/dotdot/abc'; 8 9 resolve('..', { basedir : dir }, function (err, res, pkg) { 10 t.ifError(err); 11 t.equal(res, __dirname + '/dotdot/index.js'); 12 }); 13 14 resolve('.', { basedir : dir }, function (err, res, pkg) { 15 t.ifError(err); 16 t.equal(res, dir + '/index.js'); 17 }); 18 }); 19 20 test('dotdot sync', function (t) { 21 t.plan(2); 22 var dir = __dirname + '/dotdot/abc'; 23 24 var a = resolve.sync('..', { basedir : dir }); 25 t.equal(a, __dirname + '/dotdot/index.js'); 26 27 var b = resolve.sync('.', { basedir : dir }); 28 t.equal(b, dir + '/index.js'); 29 });