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.

54 lines
1.8 KiB

4 years ago
  1. var test = require('tape');
  2. var resolve = require('../');
  3. var path = require('path');
  4. test('shadowed core modules still return core module', function (t) {
  5. t.plan(2);
  6. resolve('util', { basedir: path.join(__dirname, 'shadowed_core') }, function (err, res) {
  7. t.ifError(err);
  8. t.equal(res, 'util');
  9. });
  10. });
  11. test('shadowed core modules still return core module [sync]', function (t) {
  12. t.plan(1);
  13. var res = resolve.sync('util', { basedir: path.join(__dirname, 'shadowed_core') });
  14. t.equal(res, 'util');
  15. });
  16. test('shadowed core modules return shadow when appending `/`', function (t) {
  17. t.plan(2);
  18. resolve('util/', { basedir: path.join(__dirname, 'shadowed_core') }, function (err, res) {
  19. t.ifError(err);
  20. t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js'));
  21. });
  22. });
  23. test('shadowed core modules return shadow when appending `/` [sync]', function (t) {
  24. t.plan(1);
  25. var res = resolve.sync('util/', { basedir: path.join(__dirname, 'shadowed_core') });
  26. t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js'));
  27. });
  28. test('shadowed core modules return shadow with `includeCoreModules: false`', function (t) {
  29. t.plan(2);
  30. resolve('util', { basedir: path.join(__dirname, 'shadowed_core'), includeCoreModules: false }, function (err, res) {
  31. t.ifError(err);
  32. t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js'));
  33. });
  34. });
  35. test('shadowed core modules return shadow with `includeCoreModules: false` [sync]', function (t) {
  36. t.plan(1);
  37. var res = resolve.sync('util', { basedir: path.join(__dirname, 'shadowed_core'), includeCoreModules: false });
  38. t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js'));
  39. });