From 9f3b2181576048ba344f61c7be6271f29d8cd069 Mon Sep 17 00:00:00 2001 From: Maciej Winnicki Date: Wed, 14 Dec 2016 10:47:45 +0100 Subject: [PATCH] refactor tests --- lib/plugins/aws/invoke/index.js | 3 +-- lib/plugins/aws/invoke/index.test.js | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/plugins/aws/invoke/index.js b/lib/plugins/aws/invoke/index.js index 0faae135b..5be071a26 100644 --- a/lib/plugins/aws/invoke/index.js +++ b/lib/plugins/aws/invoke/index.js @@ -84,7 +84,6 @@ class AwsInvoke { log(invocationReply) { const color = !invocationReply.FunctionError ? 'white' : 'red'; - if (invocationReply.Payload) { const response = JSON.parse(invocationReply.Payload); @@ -120,7 +119,7 @@ class AwsInvoke { } if (invocationReply.FunctionError) { - return BbPromise.reject(new Error('Invoked function errored')); + return BbPromise.reject(new Error('Invoked function failed')); } return BbPromise.resolve(); diff --git a/lib/plugins/aws/invoke/index.test.js b/lib/plugins/aws/invoke/index.test.js index cc4b7b4e4..4ad9c76c2 100644 --- a/lib/plugins/aws/invoke/index.test.js +++ b/lib/plugins/aws/invoke/index.test.js @@ -260,7 +260,7 @@ describe('AwsInvoke', () => { return awsInvoke.log(invocationReplyMock); }); - it('rejects the promise for failed invocations', (done) => { + it('rejects the promise for failed invocations', () => { const invocationReplyMock = { Payload: ` { @@ -271,10 +271,10 @@ describe('AwsInvoke', () => { FunctionError: true, }; - awsInvoke.log(invocationReplyMock).then(() => { - done(new Error('Promise resolved')); - }, () => { - done(); + return awsInvoke.log(invocationReplyMock).catch(err => { + expect(err).to + .and.be.instanceof(Error) + .and.have.property('message', 'Invoked function failed'); }); }); });