You've already forked serverless-offline
mirror of
https://github.com/encounter/serverless-offline.git
synced 2026-03-30 11:37:53 -07:00
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
/* global describe before context it */
|
|
|
|
'use strict';
|
|
|
|
const chai = require('chai');
|
|
const dirtyChai = require('dirty-chai');
|
|
const functionHelper = require('../../src/functionHelper');
|
|
|
|
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', () => {
|
|
expect(result.funTimeout).to.eql(30000);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|
|
});
|
|
});
|