test2.js
1.31 KB
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
30
31
32
33
34
35
36
37
var path = require('path');
var assert = require('assert');
var expect = require('chai').expect;
require('./test-helper-code.js');
describe("support for test code", function() {
it("should load up a module in a path defined in test helper code", function() {
require('module-a').sayHello();
require('module-b').sayHello();
});
it("should not search paths that have been removed", function() {
require('module-c').sayHello();
require('../').removePath(path.join(__dirname, 'src'));
assert.throws(function() {
require('module-d').sayHello();
});
});
it("should allow specific directory to be enabled", function() {
var targetDir = path.dirname(require.resolve('installed-module-allowed-explicit'));
require('../').addPath(targetDir);
require('../').enableForDir(targetDir);
var foo = require('installed-module-allowed-explicit').getFoo();
expect(foo.name).to.equal('installed-module-allowed-explicit-foo');
});
it("should allow directories where loaded", function() {
require('../').addPath(path.join(__dirname, 'src'));
var foo = require('installed-module-allowed').getFoo();
expect(foo.name).to.equal('installed-module-allowed-foo');
});
});
console.log('All tests passed!');