Skip to content

Commit

Permalink
adding validation and tests for plugins and config options
Browse files Browse the repository at this point in the history
  • Loading branch information
reaganthomas committed Jun 30, 2015
1 parent 768cc7e commit 767318e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions build/validation.js
Expand Up @@ -19,6 +19,14 @@ module.exports = {
if (typeof options.configFile !== 'string') {
throw new Error('Config file must be a string containing the relative path to a config file');
}

if (typeof options.config !== 'object') {
throw new Error('Config must be an object containing configuration options for your gulp tasks');
}

if (typeof options.plugins !== 'object') {
throw new Error('Plugins must be an object containing plugins you wish to use in your gulp tasks');
}
},

validateTaskDirectory: function validateTaskDirectory(taskDirectory) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "gulp-simple-task-loader",
"version": "1.2.0",
"version": "1.2.1",
"description": "A simple task loader for gulp",
"keywords": [
"gulp",
Expand Down
8 changes: 8 additions & 0 deletions src/validation.js
Expand Up @@ -19,6 +19,14 @@ module.exports = {
if(typeof options.configFile !== 'string') {
throw new Error('Config file must be a string containing the relative path to a config file');
}

if(typeof options.config !== 'object') {
throw new Error('Config must be an object containing configuration options for your gulp tasks');
}

if(typeof options.plugins !== 'object') {
throw new Error('Plugins must be an object containing plugins you wish to use in your gulp tasks');
}
},

validateTaskDirectory: function(taskDirectory) {
Expand Down
14 changes: 14 additions & 0 deletions test/index.spec.js
Expand Up @@ -64,6 +64,20 @@ describe('gulp-simple-task-loader', function() {
done();
});

it('should error when config is not an object', function(done) {
assert.throws(function() {
require(taskLoader)({ config: '' });
}, Error);
done();
});

it('should error when plugins is not an object', function(done) {
assert.throws(function() {
require(taskLoader)({ plugins: '' });
}, Error);
done();
});

it('should skip files that are directories', function(done) {
require(taskLoader)({
taskDirectory: 'test/test-tasks',
Expand Down

0 comments on commit 767318e

Please sign in to comment.