2017-01-05 09:57:57 +01:00
|
|
|
/* global describe before context it */
|
2017-01-05 15:50:05 +01:00
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2016-10-23 20:18:19 -03:00
|
|
|
const chai = require('chai');
|
|
|
|
|
const dirtyChai = require('dirty-chai');
|
2016-10-24 20:07:24 -03:00
|
|
|
const functionHelper = require('../../src/functionHelper');
|
2016-10-23 20:18:19 -03:00
|
|
|
|
|
|
|
|
const expect = chai.expect;
|
|
|
|
|
chai.use(dirtyChai);
|
|
|
|
|
|
|
|
|
|
describe('functionHelper', () => {
|
|
|
|
|
describe('#getFunctionOptions', () => {
|
|
|
|
|
|
|
|
|
|
const funName = 'testFunction';
|
|
|
|
|
const servicePath = 'src';
|
|
|
|
|
|
|
|
|
|
let result;
|
|
|
|
|
before(() => {
|
|
|
|
|
const fun = {
|
|
|
|
|
handler: 'handler.hello',
|
|
|
|
|
};
|
|
|
|
|
result = functionHelper.getFunctionOptions(fun, funName, servicePath);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have the correct funName', () => {
|
|
|
|
|
expect(result.funName).to.eq(funName);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have the correct handler name', () => {
|
|
|
|
|
expect(result.handlerName).to.eq('hello');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have the correct handler path', () => {
|
|
|
|
|
expect(result.handlerPath).to.eq('src/handler');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have the default timeout', () => {
|
2017-03-19 12:49:17 +01:00
|
|
|
expect(result.funTimeout).to.eql(30000);
|
2016-10-23 20:18:19 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have babelOptions undefined', () => {
|
|
|
|
|
expect(result.babelOptions).to.be.undefined();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
context('with a timeout', () => {
|
|
|
|
|
before(() => {
|
|
|
|
|
const fun = {
|
|
|
|
|
handler: 'handler.hello',
|
|
|
|
|
timeout: 7,
|
|
|
|
|
};
|
|
|
|
|
result = functionHelper.getFunctionOptions(fun, funName, servicePath);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have the correct timeout', () => {
|
|
|
|
|
expect(result.funTimeout).to.eql(7000);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|