dotdot.js 763 B

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