proxyquire-sub-dependencies.js
740 Bytes
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
38
'use strict';
/*jshint asi:true*/
/*global describe, before, beforeEach, it */
var assert = require('assert')
, proxyquire = require('..')
;
describe('When resolving foo that requires bar and stubbed baz where bar requires unstubbed baz', function () {
var bazStub
, foo
, baz
;
before(function () {
bazStub = {
testexport: 'stubbed'
};
foo = proxyquire('./samples/sub-dependencies/foo', {
'./baz': bazStub
});
baz = require('./samples/sub-dependencies/baz');
})
it('does not stub baz in bar', function () {
assert.equal(foo.bar.baz.testexport, 'test');
})
it('does not affect a normal baz import', function () {
assert.equal(baz.testexport, 'test');
})
});