aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/fixtures/an (odd) filename.js1
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/helper.js61
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/test.js133
3 files changed, 195 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/fixtures/an (odd) filename.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/fixtures/an (odd) filename.js
new file mode 100644
index 00000000..fbf9f2b3
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/fixtures/an (odd) filename.js
@@ -0,0 +1 @@
+var odd = true; \ No newline at end of file
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/helper.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/helper.js
new file mode 100644
index 00000000..0fb0b256
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/helper.js
@@ -0,0 +1,61 @@
+
+var EventEmitter = require('events').EventEmitter,
+ assert = require('assert'),
+ tests = {};
+
+module.exports = test;
+test.run = run;
+
+// ## Test helpers
+
+function test(msg, handler) {
+ tests[msg] = handler;
+}
+
+function run() {
+ var specs = Object.keys(tests),
+ specsRemaining = specs.length;
+
+ specs.forEach(function(spec) {
+ var handler = tests[spec];
+
+ // grab the set of asserts for this spec
+ var shoulds = handler(),
+ keys = Object.keys(shoulds),
+ remaining = keys.length;
+
+ keys.forEach(function(should) {
+ var em = new EventEmitter(),
+ to = setTimeout(function() {
+ assert.fail('never ended');
+ }, 5000);
+
+ em
+ .on('error', function assertFail(err) { assert.fail(err) })
+ .on('end', function assertOk() {
+ clearTimeout(to);
+ shoulds[should].status = true;
+
+ // till we get to 0
+ if(!(--remaining)) {
+ console.log([
+ '',
+ '» ' + spec,
+ keys.map(function(k) { return ' » ' + k; }).join('\n'),
+ '',
+ ' Total: ' + keys.length,
+ ' Failed: ' + keys.map(function(item) { return shoulds[should].status; }).filter(function(status) { return !status; }).length,
+ ''
+ ].join('\n'));
+
+ if(!(--specsRemaining)) {
+ console.log('All done');
+ }
+
+ }
+ });
+
+ shoulds[should](em);
+ });
+ });
+}
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/test.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/test.js
new file mode 100644
index 00000000..3df267a4
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fileset/tests/test.js
@@ -0,0 +1,133 @@
+
+var EventEmitter = require('events').EventEmitter,
+ fileset = require('../'),
+ assert = require('assert'),
+ test = require('./helper');
+
+// Given a **.coffee pattern
+test('Given a **.md pattern', function() {
+
+ return {
+ 'should return the list of matching file in this repo': function(em) {
+ fileset('*.md', function(err, results) {
+ if(err) return em.emit('error', err);
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.ok(results.length, 'should return at least one element');
+ assert.equal(results.length, 1, 'actually, should return only one');
+ em.emit('end');
+ });
+ }
+ }
+});
+
+test('Say we want the **.js files, but not those in node_modules', function() {
+
+ return {
+ 'Should recursively walk the dir and return the matching list': function(em) {
+ fileset('**/*.js', 'node_modules/**', function(err, results) {
+ if(err) return em.emit('error', err);
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 4);
+ em.emit('end');
+ });
+ },
+
+ 'Should support multiple paths at once': function(em) {
+ fileset('**/*.js *.md', 'node_modules/**', function(err, results) {
+ if(err) return em.emit('error', err);
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 5);
+
+ assert.deepEqual(results, [
+ 'README.md',
+ 'lib/fileset.js',
+ 'tests/fixtures/an (odd) filename.js',
+ 'tests/helper.js',
+ 'tests/test.js'
+ ]);
+
+ em.emit('end');
+ });
+ },
+
+ 'Should support multiple paths for excludes as well': function(em) {
+ fileset('**/*.js *.md', 'node_modules/** **.md tests/*.js', function(err, results) {
+ if(err) return em.emit('error', err);
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 2);
+
+ assert.deepEqual(results, [
+ 'lib/fileset.js',
+ 'tests/fixtures/an (odd) filename.js',
+ ]);
+
+ em.emit('end');
+ });
+ }
+ }
+});
+
+
+test('Testing out emmited events', function() {
+
+ // todos: the tests for match, include, exclude events, but seems like it's ok
+ return {
+ 'Should recursively walk the dir and return the matching list': function(em) {
+ fileset('**/*.js', 'node_modules/**')
+ .on('error', em.emit.bind(em, 'error'))
+ .on('end', function(results) {
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 4);
+ em.emit('end');
+ });
+ },
+
+ 'Should support multiple paths at once': function(em) {
+ fileset('**/*.js *.md', 'node_modules/**')
+ .on('error', em.emit.bind(em, 'error'))
+ .on('end', function(results) {
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 5);
+
+ assert.deepEqual(results, [
+ 'README.md',
+ 'lib/fileset.js',
+ 'tests/fixtures/an (odd) filename.js',
+ 'tests/helper.js',
+ 'tests/test.js'
+ ]);
+
+ em.emit('end');
+ });
+ }
+ }
+});
+
+
+test('Testing patterns passed as arrays', function() {
+
+ return {
+ 'Should match files passed as an array with odd filenames': function(em) {
+ fileset(['lib/*.js', 'tests/fixtures/an (odd) filename.js'], ['node_modules/**'])
+ .on('error', em.emit.bind(em, 'error'))
+ .on('end', function(results) {
+ assert.ok(Array.isArray(results), 'should be an array');
+ assert.equal(results.length, 2);
+
+ assert.deepEqual(results, [
+ 'lib/fileset.js',
+ 'tests/fixtures/an (odd) filename.js',
+ ]);
+
+ em.emit('end');
+ });
+ }
+ }
+
+});
+
+
+
+test.run();
+
+