Added test for DLRs to long messages

This commit is contained in:
2015-06-11 20:41:47 +02:00
parent 4d1d44ff55
commit 3a8bb6846c
+72
View File
@@ -224,4 +224,76 @@ describe('Sessions', function() {
});
});
it('should send a long sms and receive dlrs for it', function(done) {
portfinder.getPort(function(err, freePort) {
assert( ! err, 'Error should not be negative');
larvitsmpp.server({
'port': freePort
}, function(err, serverSession) {
assert( ! err, 'Error should not be negative');
serverSession.on('sms', function(sms) {
sms.smsId = 2343;
sms.sendResp(function(err) {
assert( ! err, 'Error should not be negative');
assert(sms.dlr === true, 'sms.dlr should be true');
// Send the DLR(s)
sms.sendDlr(true);
});
});
serverSession.on('close', function() {
// Manually destroy the server socket
serverSession.sock.destroy();
});
});
larvitsmpp.client({
'port': freePort
}, function(err, clientSession) {
var sentSmsId;
assert( ! err, 'Error should not be negative');
clientSession.on('dlr', function(dlr) {
assert(dlr.statusMsg === 'DELIVERED', 'DLR statusMsg should be "DELIVERED"');
assert(dlr.smsId.toString() === sentSmsId.toString(), 'SmsId should be "' + sentSmsId.toString() + '"');
// Gracefully close connection
clientSession.unbind();
done();
});
clientSession.sendSms({
'from': 'foo',
'to': '46709771337',
'message': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised.',
'dlr': true
}, function(err, smsIds, retPduObjs) {
assert( ! err, 'Error should not be negative');
assert(smsIds instanceof Array, 'smsIds should be an Array');
assert(smsIds[0] === '2343-1', 'First smsId should be "2343-1"');
assert(smsIds[1] === '2343-2', 'Second smsId should be "2343-2"');
assert(smsIds[2] === '2343-3', 'Third smsId should be "2343-3"');
assert(smsIds[3] === undefined, 'Fourth smsId should be undefined');
assert(retPduObjs[0].cmdStatus === 'ESME_ROK', 'Command status should be "ESME_ROK"');
assert(retPduObjs[0].cmdName === 'submit_sm_resp', 'Command name should be "submit_sm_resp"');
assert(retPduObjs[1].cmdStatus === 'ESME_ROK', 'Command status should be "ESME_ROK"');
assert(retPduObjs[1].cmdName === 'submit_sm_resp', 'Command name should be "submit_sm_resp"');
assert(retPduObjs[2].cmdStatus === 'ESME_ROK', 'Command status should be "ESME_ROK"');
assert(retPduObjs[2].cmdName === 'submit_sm_resp', 'Command name should be "submit_sm_resp"');
// Save the SMS id to match the DLR for
sentSmsId = smsIds[0].split('-')[0];
});
});
});
});
});