Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test for extra path in `addNamespace()`

  • Loading branch information...
commit f1fea57caac85963593258658127d4158c64a4fc 1 parent 99f7116
@bengourley bengourley authored
Showing with 29 additions and 1 deletion.
  1. +5 −0 test/assets-alt/d.js
  2. +24 −1 test/compact.test.js
View
5 test/assets-alt/d.js
@@ -0,0 +1,5 @@
+var square = function (x) {
+ return x * x;
+};
+
+square(10);
View
25 test/compact.test.js
@@ -4,7 +4,8 @@ var path = require('path')
, async = require('asyncjs');
var srcPath = __dirname + '/assets'
- , destPath = __dirname + '/tmp';
+ , destPath = __dirname + '/tmp'
+ , altPath = __dirname + '/assets-alt';
function createFiles(done) {
mkdirp(destPath, done);
@@ -54,6 +55,28 @@ describe('compact.js', function() {
it('should succeed with valid namespace', function() {
compact.addNamespace('global').addJs.should.be.a('function');
});
+
+ it('should add a source path to the lookup chain when given', function () {
+
+ compact.addNamespace('alternative', altPath);
+
+ // Lookup item in added path
+ (function () {
+ compact.ns.alternative.addJs('d.js');
+ }).should.not.throw();
+
+ // Lookup item in default path
+ (function () {
+ compact.ns.alternative.addJs('a.js');
+ }).should.not.throw();
+
+ // Lookup item that doesn't exist in either path
+ (function () {
+ compact.ns.alternative.addJs('xyz.js');
+ }).should.throw('Unable to find \'xyz.js\'');
+
+ });
+
});
describe('Namespace', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.