Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added tests

  • Loading branch information...
commit 2257c467546f5b5ad43e80aa342604c1a50ee80a 1 parent 2bff02d
@fent fent authored
View
4 test/controllers/main-Controller.js
@@ -0,0 +1,4 @@
+exports.index = 1;
+exports.show = 2;
+exports.add = 3;
+exports.edit = 4;
View
1  test/controllers/notthis.js
@@ -0,0 +1 @@
+exports.yes = 'no';
View
2  test/controllers/other-Controller.js
@@ -0,0 +1,2 @@
+exports.index = 1;
+exports.show = 'nothing'
View
1  test/mydir/foo.js
@@ -0,0 +1 @@
+module.exports = 'bar';
View
2  test/mydir/hello.js
@@ -0,0 +1,2 @@
+exports.world = true;
+exports.universe = 42;
View
4 test/mydir/sub/config.json
@@ -0,0 +1,4 @@
+{
+ "settingA": "A",
+ "settingB": "B"
+}
View
1  test/mydir/sub/no.2js
@@ -0,0 +1 @@
+module.exports = true;
View
1  test/mydir/sub/yes.js
@@ -0,0 +1 @@
+module.exports = true;
View
37 test/test.js
@@ -0,0 +1,37 @@
+var assert = require('assert');
+var requireAll = require('..');
+
+
+var controllers = requireAll({
+ dirname: __dirname + '/controllers',
+ filter: /(.+Controller)\.js$/
+});
+
+assert.deepEqual(controllers, {
+ 'main-Controller': {
+ index: 1,
+ show: 2,
+ add: 3,
+ edit: 4
+ },
+
+ 'other-Controller': {
+ index: 1,
+ show: 'nothing'
+ }
+});
+
+
+var mydir = requireAll({
+ dirname: __dirname + '/mydir',
+ filter: /(.+)\.(js|json)$/
+});
+
+assert.deepEqual(mydir, {
+ foo: 'bar',
+ hello: { world: true, universe: 42 },
+ sub: {
+ config: { settingA: 'A', settingB: 'B' },
+ yes: true
+ }
+});
Please sign in to comment.
Something went wrong with that request. Please try again.