From dc038d9010391fdfa21b469dd60995c9c517709d Mon Sep 17 00:00:00 2001 From: Mayur Virendra Date: Tue, 9 Apr 2024 05:38:04 +0530 Subject: [PATCH] Corrections for developer mode resolution --- services/Actions.js | 2 +- tests/unit/controllers/bot.test.js | 2 +- tests/unit/services/actions.test.js | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/services/Actions.js b/services/Actions.js index 43a3fd5..a0cf62d 100644 --- a/services/Actions.js +++ b/services/Actions.js @@ -118,7 +118,7 @@ class Actions { to: recipient.includes('whatsapp:') ? recipient : `whatsapp:${recipient}`, } - if(media_url && !process.env.DEVELOPER_MODE_ON){ + if(media_url && !parseInt(process.env.DEVELOPER_MODE_ON)){ body.mediaUrl = [media_url]; } let data = await client.messages.create(body) diff --git a/tests/unit/controllers/bot.test.js b/tests/unit/controllers/bot.test.js index 792befe..b918463 100644 --- a/tests/unit/controllers/bot.test.js +++ b/tests/unit/controllers/bot.test.js @@ -60,7 +60,7 @@ describe('Test cases for Google maps', () => { expect(source_gps).to.have.property('lng'); }) - it.only('It should take a trip plannign input and generate static route image and directions link.', async () => { + it('It should take a trip plannign input and generate static route image and directions link.', async () => { const ask = "Can you plean a trip from Denver to Yellowstone national park?"; // identify source and destination diff --git a/tests/unit/services/actions.test.js b/tests/unit/services/actions.test.js index 5f43354..0014c39 100644 --- a/tests/unit/services/actions.test.js +++ b/tests/unit/services/actions.test.js @@ -87,5 +87,13 @@ describe('should test send_message()', () => { expect(error).to.be.an.instanceOf(Error); } }); + + it('Should test sending a message with media', async () => { + const recipient = process.env.TEST_RECEPIENT_NUMBER; + const message = 'This is an image'; + const media_url = 'https://becknprotocol.io/wp-content/uploads/2022/03/logo.png'; + let status = await actionsService.send_message(recipient, message, media_url); + expect(status.deliveryStatus).to.not.equal('failed') + }); });