forked from enviPath/enviPy
Current Dev State
This commit is contained in:
1
static/js/ketcher2/node_modules/fileset/tests/fixtures/an (odd) filename.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/fileset/tests/fixtures/an (odd) filename.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
var odd = true;
|
||||
61
static/js/ketcher2/node_modules/fileset/tests/helper.js
generated
vendored
Normal file
61
static/js/ketcher2/node_modules/fileset/tests/helper.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var assert = require('assert');
|
||||
var tests = {};
|
||||
|
||||
module.exports = test;
|
||||
test.run = run;
|
||||
|
||||
// ## Test helpers
|
||||
|
||||
function test(msg, handler) {
|
||||
tests[msg] = handler;
|
||||
}
|
||||
|
||||
function run() {
|
||||
var specs = Object.keys(tests);
|
||||
var specsRemaining = specs.length;
|
||||
|
||||
specs.forEach(function(spec) {
|
||||
var handler = tests[spec];
|
||||
|
||||
// grab the set of asserts for this spec
|
||||
var shoulds = handler();
|
||||
var keys = Object.keys(shoulds);
|
||||
var 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
37
static/js/ketcher2/node_modules/fileset/tests/test-sync.js
generated
vendored
Normal file
37
static/js/ketcher2/node_modules/fileset/tests/test-sync.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var fileset = require('../');
|
||||
var assert = require('assert');
|
||||
var test = require('./helper');
|
||||
|
||||
// Given a **.md pattern
|
||||
test('Sync API - Given a **.md pattern', function() {
|
||||
return {
|
||||
'should return the list of matching file in this repo': function(em) {
|
||||
var results = fileset.sync('*.md', 'node_modules/**/*.md');
|
||||
|
||||
assert.ok(Array.isArray(results), 'should be an array');
|
||||
assert.ok(results.length, 'should return at least one element');
|
||||
assert.equal(results.length, 2, 'actually, should return only two');
|
||||
|
||||
em.emit('end');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Sync API - Given a *.md and **.js pattern, and two exclude', function() {
|
||||
return {
|
||||
'should return the list of matching file in this repo': function(em) {
|
||||
var results = fileset.sync('*.md *.js', 'CHANGELOG.md node_modules/**/*.md node_modules/**/*.js');
|
||||
|
||||
assert.ok(Array.isArray(results), 'should be an array');
|
||||
assert.ok(results.length, 'should return at least one element');
|
||||
|
||||
assert.equal(results.length, 6, 'actually, should return only six');
|
||||
|
||||
em.emit('end');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test.run();
|
||||
137
static/js/ketcher2/node_modules/fileset/tests/test.js
generated
vendored
Normal file
137
static/js/ketcher2/node_modules/fileset/tests/test.js
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var fileset = require('../');
|
||||
var assert = require('assert');
|
||||
var test = require('./helper');
|
||||
|
||||
// Given a **.md 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, 2, 'actually, should return only two');
|
||||
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, 5);
|
||||
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, 7);
|
||||
|
||||
assert.deepEqual(results, [
|
||||
'CHANGELOG.md',
|
||||
'README.md',
|
||||
'lib/fileset.js',
|
||||
'tests/fixtures/an (odd) filename.js',
|
||||
'tests/helper.js',
|
||||
'tests/test-sync.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, 5);
|
||||
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, 7);
|
||||
|
||||
assert.deepEqual(results, [
|
||||
'CHANGELOG.md',
|
||||
'README.md',
|
||||
'lib/fileset.js',
|
||||
'tests/fixtures/an (odd) filename.js',
|
||||
'tests/helper.js',
|
||||
'tests/test-sync.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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user