source: imaps-frontend/node_modules/resolve/test/module_dir.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[d565449]1var path = require('path');
2var test = require('tape');
3var resolve = require('../');
4
5test('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
27test('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});
Note: See TracBrowser for help on using the repository browser.