Added test for readme example and added more logging
This commit is contained in:
@@ -105,6 +105,7 @@ function client(options, callback) {
|
||||
'enqLinkTiming': 20000 // 20 sec
|
||||
}, options || {});
|
||||
|
||||
log.debug('larvitsmpp: lib/client.js: client() - Connecting to ' + options.host + ':' + options.port);
|
||||
sock.connect(options.port, options.host, function() {
|
||||
var session = clientSession(sock, options);
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
"url": "https://github.com/larvit/larvitsmpp",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.11",
|
||||
"readmeFilename": "README.md",
|
||||
"readme": "larvitsmpp",
|
||||
"bugs": {
|
||||
|
||||
+65
-2
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var larvitsmpp = require('../larvitsmpp'),
|
||||
assert = require('assert'),
|
||||
portfinder = require('portfinder');
|
||||
portfinder = require('portfinder'),
|
||||
assert = require('assert');
|
||||
|
||||
// Very advanced auth system
|
||||
function checkuserpass(username, password, callback) {
|
||||
@@ -363,4 +363,67 @@ describe('Sessions', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should verify dlr on readme example', 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; // Random integer
|
||||
|
||||
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();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
larvitsmpp.client({
|
||||
'port': freePort
|
||||
}, function(err, clientSession) {
|
||||
assert( ! err, 'Error should not be negative');
|
||||
|
||||
clientSession.on('dlr', function(dlr, dlrPduObj) {
|
||||
assert.deepEqual(dlr.statusMsg, 'DELIVERED');
|
||||
assert.deepEqual(dlr.statusId, 2);
|
||||
assert.deepEqual(parseInt(dlr.smsId), 2343);
|
||||
|
||||
assert.deepEqual(dlrPduObj.params.short_message.substring(0, 36), 'id:2343 sub:001 dlvrd:1 submit date:');
|
||||
assert.deepEqual(dlrPduObj.params.short_message.substring(68), 'stat:DELIVRD err:0 text:xxx');
|
||||
assert.deepEqual(dlrPduObj.cmdStatus, 'ESME_ROK');
|
||||
assert.deepEqual(dlrPduObj.cmdName, 'deliver_sm');
|
||||
|
||||
// Gracefully close connection
|
||||
clientSession.unbind();
|
||||
});
|
||||
|
||||
clientSession.sendSms({
|
||||
'from': '46701113311',
|
||||
'to': '46709771337',
|
||||
'message': '«baff»',
|
||||
'dlr': true
|
||||
}, function(err, smsId, retPduObj) {
|
||||
assert( ! err, 'Error should not be negative');
|
||||
assert.deepEqual(parseInt(smsId[0]), 2343);
|
||||
assert.deepEqual(smsId[1], undefined);
|
||||
assert.deepEqual(retPduObj[0].cmdStatus, 'ESME_ROK');
|
||||
assert.deepEqual(retPduObj[0].cmdName, 'submit_sm_resp');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user