[d565449] | 1 | var path = require('path');
|
---|
| 2 | var test = require('tape');
|
---|
| 3 | var resolve = require('../');
|
---|
| 4 |
|
---|
| 5 | test('moduleDirectory strings', function (t) {
|
---|
| 6 | t.plan(4);
|
---|
| 7 | var dir = path.join(__dirname, 'module_dir');
|
---|
| 8 | var xopts = {
|
---|
| 9 | basedir: dir,
|
---|
| 10 | moduleDirectory: 'xmodules'
|
---|
| 11 | };
|
---|
| 12 | resolve('aaa', xopts, function (err, res, pkg) {
|
---|
| 13 | t.ifError(err);
|
---|
| 14 | t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
---|
| 15 | });
|
---|
| 16 |
|
---|
| 17 | var yopts = {
|
---|
| 18 | basedir: dir,
|
---|
| 19 | moduleDirectory: 'ymodules'
|
---|
| 20 | };
|
---|
| 21 | resolve('aaa', yopts, function (err, res, pkg) {
|
---|
| 22 | t.ifError(err);
|
---|
| 23 | t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
---|
| 24 | });
|
---|
| 25 | });
|
---|
| 26 |
|
---|
| 27 | test('moduleDirectory array', function (t) {
|
---|
| 28 | t.plan(6);
|
---|
| 29 | var dir = path.join(__dirname, 'module_dir');
|
---|
| 30 | var aopts = {
|
---|
| 31 | basedir: dir,
|
---|
| 32 | moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
---|
| 33 | };
|
---|
| 34 | resolve('aaa', aopts, function (err, res, pkg) {
|
---|
| 35 | t.ifError(err);
|
---|
| 36 | t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
---|
| 37 | });
|
---|
| 38 |
|
---|
| 39 | var bopts = {
|
---|
| 40 | basedir: dir,
|
---|
| 41 | moduleDirectory: ['zmodules', 'ymodules', 'xmodules']
|
---|
| 42 | };
|
---|
| 43 | resolve('aaa', bopts, function (err, res, pkg) {
|
---|
| 44 | t.ifError(err);
|
---|
| 45 | t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
---|
| 46 | });
|
---|
| 47 |
|
---|
| 48 | var copts = {
|
---|
| 49 | basedir: dir,
|
---|
| 50 | moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
---|
| 51 | };
|
---|
| 52 | resolve('bbb', copts, function (err, res, pkg) {
|
---|
| 53 | t.ifError(err);
|
---|
| 54 | t.equal(res, path.join(dir, '/zmodules/bbb/main.js'));
|
---|
| 55 | });
|
---|
| 56 | });
|
---|