<commit_before>var should = require('should');
var actionheroPrototype = require(__dirname + '/../../actionhero.js').actionheroPrototype;
var actionhero = new actionheroPrototype();
var api;

describe('Action Input Params', function(){

  before(function(done){
    actionhero.start(function(err, a){
      api = a;
      
      api.actions.versions.testAction = [1]
      api.actions.actions.testAction = {
        '1': {
          name: 'testAction',
          description: 'this action has some required params',
          version: 1,
          inputs: { required: [ 'testParam' ], optional: [] },
          outputExample: {},
          run:function(api, connection, next){
            connection.response.param = connection.params.testParam;
            next(connection, true);
          }
        }
      }
      
      done();
    })
  });

  after(function(done){
    actionhero.stop(function(){
    
      delete api.actions.actions.testAction;
      delete api.actions.versions.testAction;
      done();
    });
  });
  
  
  it('correct params that are falsey (false booleans, [])', function(done){
    api.specHelper.runAction('testAction', {testParam: false }, function(response){
      response.param.should.equal(false);
      api.specHelper.runAction('testAction', {testParam: [] }, function(response){
        response.param.should.be.Array.and.be.empty;
        api.specHelper.runAction('testAction', {testParam: '' }, function(response){
          response.error.should.containEql('required parameter for this action');
          api.specHelper.runAction('testAction', { }, function(response){
            response.error.should.containEql('required parameter for this action');
            done();
          });
        });
      });
    });
  });
  
  it('correct params respect config options', function(done){
  	api.config.general.missingParamChecks = [ undefined ]
    api.specHelper.runAction('testAction', {testParam: '' }, function(response){
      response.param.should.equal('');
      api.specHelper.runAction('testAction', {testParam: null }, function(response){
      	should(response.param).eql(null);
        done();
      });
    });
  });

});<commit_msg>moved default case to separate test<commit_after>var should = require('should');
var actionheroPrototype = require(__dirname + '/../../actionhero.js').actionheroPrototype;
var actionhero = new actionheroPrototype();
var api;

describe('Action Input Params', function(){

  before(function(done){
    actionhero.start(function(err, a){
      api = a;
      
      api.actions.versions.testAction = [1]
      api.actions.actions.testAction = {
        '1': {
          name: 'testAction',
          description: 'this action has some required params',
          version: 1,
          inputs: { required: [ 'testParam' ], optional: [] },
          outputExample: {},
          run:function(api, connection, next){
            connection.response.param = connection.params.testParam;
            next(connection, true);
          }
        }
      }
      
      done();
    })
  });

  after(function(done){
    actionhero.stop(function(){
    
      delete api.actions.actions.testAction;
      delete api.actions.versions.testAction;
      done();
    });
  });
  
  
  it('correct params that are falsey (false booleans, [])', function(done){
    api.specHelper.runAction('testAction', {testParam: false }, function(response){
      response.param.should.equal(false);
      api.specHelper.runAction('testAction', {testParam: [] }, function(response){
        response.param.should.be.Array.and.be.empty;
        done();
      });
    });
  });
  
  it( 'will fail for missing or empty string params', function(done){
    api.specHelper.runAction('testAction', {testParam: '' }, function(response){
      response.error.should.containEql('required parameter for this action');
      api.specHelper.runAction('testAction', { }, function(response){
        response.error.should.containEql('required parameter for this action');
        done();
      });
    });
  } );
  
  it('correct params respect config options', function(done){
  	api.config.general.missingParamChecks = [ undefined ]
    api.specHelper.runAction('testAction', {testParam: '' }, function(response){
      response.param.should.equal('');
      api.specHelper.runAction('testAction', {testParam: null }, function(response){
      	should(response.param).eql(null);
        done();
      });
    });
  });

});
{'fraction_non_alphanumeric': 0.1505592841163311, 'fraction_numerical': 0.0013422818791946308, 'mean_word_length': 2.795415959252971, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3802498', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1244, 'n_words': 232}