Skip to content

Commit

Permalink
updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-leopold committed Oct 27, 2015
1 parent 55e3eba commit f4aa2fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/mundler.js
Expand Up @@ -449,7 +449,7 @@ Mundler.prototype.configureVendorBundle = function(bundleName, props, parentBund
var filePath, moduleList, dest;
var self = this;
var modules = [];
var moduleCache = this.moduleCache[parentBundle];
var moduleCache = this.moduleCache[parentBundle] || {};
var vprops = assign({}, props);
var b = browserify(props.browserifyOpts || {});
vprops.watch = false;
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.js
Expand Up @@ -22,7 +22,7 @@ describe('mundlerInit', function() {
it('should accept an object being passed in', function() {
var m = Mundler(testConfig);
var defaults = {
options: testConfig,
bundles: testConfig,
watchAll: false,
watch: false,
vendorBundleCache: {}
Expand All @@ -37,7 +37,7 @@ describe('mundlerInit', function() {
var m = Mundler(null, { config: './test/helpers/testConfig.js' });

var defaults = {
options: testConfig,
bundles: testConfig,
watchAll: false,
watch: false,
vendorBundleCache: {}
Expand Down
38 changes: 10 additions & 28 deletions test/lib/mundler.test.js
Expand Up @@ -65,22 +65,22 @@ describe('lib/mundler', function() {
});

it('should find all requires/imports', function() {
var expectedValues = ['fs', 'path', 'child_process', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.searchForDependencies('test', [path.resolve('test/fixtures/sample.js')], testConfig.test).should.eventually.deep.equal(expectedValues);
var expectedModules = ['fs', 'path', 'util', 'events', 'child_process', 'stream', 'vinyl', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.searchForDependencies('test', [path.resolve('test/fixtures/sample.js')], testConfig.test).should.eventually.deep.equal(expectedModules);
});

});

describe('#buildDependencyList()', function() {

it('should return object containing array of external module dependencies', function() {
var expectedValues = ['fs', 'path', 'child_process', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.buildDependencyList('test', testConfig.test).should.eventually.deep.equal(expectedValues);
var expectedModules = ['fs', 'path', 'util', 'events', 'child_process', 'stream', 'vinyl', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.buildDependencyList('test', testConfig.test).should.eventually.deep.equal(expectedModules);
});

it('should work if no CWD is set', function() {
var expectedValues = ['fs', 'path', 'child_process', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.buildDependencyList('test', testConfigNoCwd.test).should.eventually.deep.equal(expectedValues);
var expectedModules = ['fs', 'path', 'util', 'events', 'child_process', 'stream', 'vinyl', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk', 'chai'];
return m.buildDependencyList('test', testConfigNoCwd.test).should.eventually.deep.equal(expectedModules);
});

});
Expand All @@ -98,12 +98,12 @@ describe('lib/mundler', function() {
});

it('should recurse if match is internal', function() {
var expectedmodules = ['fs', 'path', 'child_process', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk'];
var expectedModules = ['fs', 'path', 'util', 'events', 'child_process', 'stream', 'vinyl', 'object-assign', 'browserify', 'watchify', 'bluebird', 'glob', 'chalk'];
var spy = sinon.spy(m, 'processMatch');

return m.processMatch('test', [path.resolve('test/fixtures/sample.js')], '../../lib/mundler', testConfig.test).then(function(modules) {
spy.should.have.been.callCount(10); // once for initial call and once for each module found (modules in array above)
modules.should.deep.equal(expectedmodules);
spy.should.have.been.callCount(14); // once for initial call and once for each module found (modules in array above)
modules.should.deep.equal(expectedModules);
});
});

Expand Down Expand Up @@ -165,25 +165,7 @@ describe('lib/mundler', function() {
setTimeout(function() {
spy.should.have.been.calledOnce;
done();
}, 1000);
});

});

describe('#configureVendorBundle()', function() {

it('should configure vendor bundle and call Mundler.createBundle()', function() {
var spy = sinon.spy(m, 'createBundle');
var modules = ['fs', 'path', 'browserify', 'watchify', 'bluebird', 'chalk'];

m.configureVendorBundle('vendor-test', { vendorDest: path.resolve('test/output/test.js') }, modules);
spy.should.have.been.calledOnce;
});

it('should not call Mundler.createBundle() if no modules or aliases are passed', function() {
var spy = sinon.spy(m, 'createBundle');
m.configureVendorBundle('vendor-test', { vendorDest: path.resolve('test/output/test.js') });
spy.should.not.have.been.called;
}, 1500);
});

});
Expand Down

0 comments on commit f4aa2fe

Please sign in to comment.