fix tests

This commit is contained in:
Nik Graf 2016-12-14 13:47:21 +01:00
parent c7df447589
commit 5a9d9feebb
2 changed files with 5 additions and 29 deletions

View File

@ -17,6 +17,7 @@ class AwsCompileAlexaSkillEvents {
const functionObj = this.serverless.service.getFunction(functionName);
if (functionObj.events) {
console.log(functionObj.events);
functionObj.events.forEach(event => {
if (event === 'alexaSkill') {
const lambdaLogicalId = this.provider.naming
@ -45,7 +46,7 @@ class AwsCompileAlexaSkillEvents {
_.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
permissionCloudForamtionResource);
} else {
} else if (event.alexaSkill) {
const errorMessage = [
`Alexa Skill event of function "${functionName}" is not an object or string.`,
' The correct syntax is: alexaSkill.',

View File

@ -25,7 +25,7 @@ describe('AwsCompileAlexaSkillEvents', () => {
});
describe('#compileAlexaSkillEvents()', () => {
it('should throw an error if alexaSkill event type is not an object', () => {
it('should throw an error if alexaSkill event is not an string', () => {
awsCompileAlexaSkillEvents.serverless.service.functions = {
first: {
events: [
@ -39,15 +39,11 @@ describe('AwsCompileAlexaSkillEvents', () => {
expect(() => awsCompileAlexaSkillEvents.compileAlexaSkillEvents()).to.throw(Error);
});
it('should create corresponding resources when event is given and enabled', () => {
it('should create corresponding resources when a alexaSkill event is provided', () => {
awsCompileAlexaSkillEvents.serverless.service.functions = {
first: {
events: [
{
alexaSkill: {
enabled: true,
},
},
'alexaSkill',
],
},
};
@ -72,27 +68,6 @@ describe('AwsCompileAlexaSkillEvents', () => {
).to.equal('alexa-appkit.amazon.com');
});
it('should not create corresponding resources when event is given but not enabled', () => {
awsCompileAlexaSkillEvents.serverless.service.functions = {
first: {
events: [
{
alexaSkill: {
enabled: false,
},
},
],
},
};
awsCompileAlexaSkillEvents.compileAlexaSkillEvents();
expect(
awsCompileAlexaSkillEvents.serverless.service.provider
.compiledCloudFormationTemplate.Resources
).to.deep.equal({});
});
it('should not create corresponding resources when alexaSkill event is not given', () => {
awsCompileAlexaSkillEvents.serverless.service.functions = {
first: {