From 9223f53296ce7d8287637e713f4ed55327c3e8fe Mon Sep 17 00:00:00 2001 From: Kaushik Das Date: Wed, 26 Jul 2023 21:32:54 +0530 Subject: [PATCH] SMS-6061 adding unit tests --- lib/resources/messages.js | 4 ++-- test/messages.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/resources/messages.js b/lib/resources/messages.js index c2057a63..d30f28be 100644 --- a/lib/resources/messages.js +++ b/lib/resources/messages.js @@ -196,7 +196,7 @@ export class MessageInterface extends PlivoResourceInterface { * @param {string} [optionalParams.method] The method used to call the url. Defaults to POST. * @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. * @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string - * @param {Template} [optionalParams.template] //add desc + * @param {Template} [optionalParams.template] //For sending templated whatsapp messages * @promise {object} return {@link PlivoGenericMessage} object if success * @fail {Error} return Error */ @@ -276,7 +276,7 @@ export class MessageInterface extends PlivoResourceInterface { } if ((params.type === 'whatsapp') && !src){ - let errorText = 'Src parameter not present' + let errorText = 'src parameter not present' return new Promise(function(resolve, reject) { reject(new Error(errorText)); }); diff --git a/test/messages.js b/test/messages.js index 52007a0c..b54a9c1e 100644 --- a/test/messages.js +++ b/test/messages.js @@ -89,6 +89,20 @@ describe('message', function () { }) }); + it('should throw error - src parameter not present', function () { + return client.messages.create({src:null, dst:'dst', text:'text',type:'whatsapp', powerpackUUID:'916386027476'}) + .catch(function (err) { + assert.equal(err.message, 'src parameter not present') + }) + }); + + it('should throw error - Template paramater is only applicable when message_type is whatsapp', function () { + return client.messages.create({src:'91235456917375', dst:'dst', text:'text',type:'sms',template: {name: "plivo_verification", language: "en_US",}, powerpackUUID:null}) + .catch(function (err) { + assert.equal(err.message, 'Template paramater is only applicable when message_type is whatsapp') + }) + }); + it('should list media via plivo interface!', function (done) { client.messages.listMedia('xyz') .then(function (mmsMedia) {