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