From c788f9ae2dd828407f185a3f19257f93d454a9ff Mon Sep 17 00:00:00 2001 From: lilleman Date: Fri, 1 May 2015 14:32:21 +0200 Subject: [PATCH] More tests to test custom params on return PDUs --- test/03_pdu.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/03_pdu.js b/test/03_pdu.js index 44e1808..3e737a2 100644 --- a/test/03_pdu.js +++ b/test/03_pdu.js @@ -246,6 +246,47 @@ describe('PDU convertion', function() { }); }); + it('should create a valid return PDU with custom param', function(done) { + var pduObj = { + 'cmdName': 'deliver_sm', + 'seqNr': 393, + 'cmdStatus': 'ESME_ROK', + 'params': { + 'source_addr': '46701113311', + 'destination_addr': '46709771337', + 'esm_class': 4, + 'short_message': 'random stuff', + 'message_id': 'od9s2' + }, + 'tlvs': { + 'receipted_message_id': { + 'tagId': 0x001E, + 'tagName': 'receipted_message_id', + 'tagValue': '293f293' + }, + '5142': { + 'tagId': 5142, + 'tagName': 'Nils', + 'tagValue': new Buffer('blajfoo', 'ascii') + } + } + }; + + larvitsmpp.utils.pduReturn(pduObj, 'ESME_RINVMSGID', {'message_id': 'mep'}, function(err, pduBuffer) { + assert( ! err, 'Error should be negative'); + + larvitsmpp.utils.pduToObj(pduBuffer, function(err, retPduObj) { + assert( ! err, 'Error should be negative'); + + assert(retPduObj.cmdName === 'deliver_sm_resp', 'Command name should be "deliver_sm_resp"'); + assert(retPduObj.cmdStatus === 'ESME_RINVMSGID', 'Command status should be ESME_RINVMSGID'); + assert(retPduObj.params.message_id === 'mep', 'message_id should be the overriden one'); + + done(); + }); + }); + }); + }); }); \ No newline at end of file