it('Should fail when trying to query for a registered reader', () => { try{ Mebo.Handler.registeredReader('EmptyHandler'); } catch(err){ if (!minimatch(err.message, 'Reader is not registered for handler *!')){ throw err; } } });
gulp.task('unzip-7zip', function() { return gulp.src(zaZip) .pipe(unzip({ filter : function(entry) { return minimatch(entry.path, '**/7za.exe'); } })) .pipe(gulp.dest(config.buildFolderRoot)); });
const matchesIgnoredPatterns = (filename, patternsToIgnore) => ( patternsToIgnore.some((ignorePattern) => minimatch(filename, ignorePattern)) )
it('Should fail if an item inside of the vector does not exist', (done) => { (async () => { const input = Input.create('input: filePath[]', {exists: true}); input.setValue([largeFilePath, largeFilePath, 'Fake!']); await input.validate(); })().then((result) => { done(new Error('Not Expected')); }).catch((err) => { done(minimatch(err.code, 'dedf89bc-c57a-4ce7-ab84-f84f49144230') ? null : err); }); });
it('Value assigned to the input should be set as immutable by default', () => { const inputA = new Input('input', {vector: true}); inputA.setValue([1, 2, 3]); try{ inputA.value()[1] = 'new value'; throw new Error('Unexpected result'); } catch(err){ assert(minimatch(err.message, "Cannot assign to read only property '*' of object '*'")); } });
it("Should fail in setupFrom to set a scalar input based on in a vector input without supplying 'at'", (done) => { const inputA = Input.create('input: filePath'); const inputB = Input.create('input: filePath[]'); try{ inputA.setupFrom(inputB); done(new Error('Unexpected result')); } catch(err){ done(minimatch(err.message, "Target input is not a vector, can't setup from a vector target input without supplying 'at'") ? null : err); } });
function processGlobFilter(files, glob) { return files.filter(file => minimatch(file.filename, glob, { matchBase: true })); }
it('Should not be able to set a value in a read-only input', () => { let error = null; try{ const input = new Input('test'); input.setReadOnly(true); input.setValue(10); } catch(err){ error = err; } assert(minimatch(error.message, 'Input * is read only, cannot be modified!')); });
it('Should not be able to assign a locked property', () => { let error = null; try{ const input = new Input('test'); input.assignProperty('customProperty', 10, true); input.lockProperty('customProperty'); input.assignProperty('customProperty', 20, true); } catch(err){ error = err; } assert(minimatch(error.message, 'Property * is locked!')); });
it('Should fail when querying a non-existing property', () => { let error = null; const input = new Input('inputName'); try{ input.property('non-existing'); } catch(err){ error = err; } assert(error); assert(minimatch(error.message, 'Property * is not registered!')); });
it('Should fail when trying to query for a registered writer', () => { try{ Mebo.Handler.registeredWriter('EmptyHandler'); } catch(err){ if (!minimatch(err.message, 'Writer is not registered for handler *!')){ throw err; } } });
it('Should fail when trying to create an invalid handler', () => { try{ Mebo.Handler.create('invalid'); } catch(err){ if (!minimatch(err.message, 'Handler * is not registered!')){ throw err; } } });
it('Should fail when assigning a non-existing property', () => { let error = null; const input = new Input('inputName'); try{ input.assignProperty('non-existing', 10); } catch(err){ error = err; } assert(error); assert(minimatch(error.message, 'Property * is not registered!')); });
it("Should fail in setupFrom when 'at' is specified for a scalar source input", (done) => { const inputA = Input.create('input: filePath'); const inputB = Input.create('input: filePath'); try{ inputA.setupFrom(inputB, 0); done(new Error('Unexpected result')); } catch(err){ done(minimatch(err.message, "Can't use at, since the source input is not a vector") ? null : err); } });
it("Should fail in setupFrom when 'at' is specified from a vector source input to a target vector input", (done) => { const inputA = Input.create('input: filePath[]'); const inputB = Input.create('input: filePath[]'); try{ inputA.setupFrom(inputB, 0); done(new Error('Unexpected result')); } catch(err){ done(minimatch(err.message, "Can't use at, from a source vector input to a target vector input") ? null : err); } });