Blame view

天文台pc/tianwentai-ui/node_modules/resolve/test/faulty_basedir.js 807 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  var test = require('tape');
  var path = require('path');
  var resolve = require('../');
  
  test('faulty basedir must produce error in windows', { skip: process.platform !== 'win32' }, function (t) {
      t.plan(1);
  
      var resolverDir = 'C:\\a\\b\\c\\d';
  
      resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) {
          t.equal(!!err, true);
      });
  });
  
  test('non-existent basedir should not throw when preserveSymlinks is false', function (t) {
      t.plan(2);
  
      var opts = {
          basedir: path.join(path.sep, 'unreal', 'path', 'that', 'does', 'not', 'exist'),
          preserveSymlinks: false
      };
  
      var module = './dotdot/abc';
  
      resolve(module, opts, function (err, res) {
          t.equal(err.code, 'MODULE_NOT_FOUND');
          t.equal(res, undefined);
      });
  });