You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
799 B

4 years ago
  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 = path.join(__dirname, '/dotdot/abc');
  7. resolve('..', { basedir: dir }, function (err, res, pkg) {
  8. t.ifError(err);
  9. t.equal(res, path.join(__dirname, 'dotdot/index.js'));
  10. });
  11. resolve('.', { basedir: dir }, function (err, res, pkg) {
  12. t.ifError(err);
  13. t.equal(res, path.join(dir, 'index.js'));
  14. });
  15. });
  16. test('dotdot sync', function (t) {
  17. t.plan(2);
  18. var dir = path.join(__dirname, '/dotdot/abc');
  19. var a = resolve.sync('..', { basedir: dir });
  20. t.equal(a, path.join(__dirname, 'dotdot/index.js'));
  21. var b = resolve.sync('.', { basedir: dir });
  22. t.equal(b, path.join(dir, 'index.js'));
  23. });