diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index 9b8179a..0b96c88 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -1523,7 +1523,7 @@ export function Request(config) { } // ============= Lookup =================== - else if (action == 'Lookup/Number/+14154305555' && method == 'GET') { + else if (action == 'Number//' && method == 'GET') { resolve({ response: {}, body: { diff --git a/lib/utils/jwt.js b/lib/utils/jwt.js index 5ce78d6..1ad47cd 100644 --- a/lib/utils/jwt.js +++ b/lib/utils/jwt.js @@ -38,17 +38,15 @@ export function AccessToken(authId, authToken, username, validityOptions = {}, u this.uid = uid || this.username + "-" + (new Date()).getTime(); } - -AccessToken.prototype.addVoiceGrants= function(incoming = false, outgoing = false) { +AccessToken.prototype = { + addVoiceGrants: function(incoming = false, outgoing = false) { this.grants = { voice: { incoming_allow: incoming, outgoing_allow: outgoing } }; - - } - AccessToken.prototype = { + }, toJwt: function() { let payload = { jti: this.uid, diff --git a/test/accounts.js b/test/accounts.js index ebf3e7a..64f4ea1 100644 --- a/test/accounts.js +++ b/test/accounts.js @@ -15,16 +15,13 @@ describe('Account', function () { }); it('should update Account via interface', function () { - return client.accounts.get() - .then(function(account){ - return account.update({ + return client.accounts.update({ name: 'name', city: 'city', address: 'address' - }) - .then(function(account) { - assert.equal(account.name, 'name') - }) + }) + .then(function(account) { + assert.equal(account.message, 'changed') }) }); @@ -35,7 +32,7 @@ describe('Account', function () { address: 'address' }) .then(function(account) { - assert.equal(account.name, 'name') + assert.equal(account.message, 'changed') }) }); @@ -80,17 +77,7 @@ describe('Account', function () { it('should update subAccount via interface', function () { return client.subAccounts.update(1, 'name', true) .then(function(account) { - assert.equal(account.name, 'name') - }) - }); - - it('should update subAccount', function () { - return client.subAccounts.get(1) - .then(function(subaccount){ - return subaccount.update('name', true) - }) - .then(function(account) { - assert.equal(account.name, 'name') + assert.equal(account.message, 'changed') }) }); @@ -101,15 +88,6 @@ describe('Account', function () { }) }); - it('delete subAccounts', function () { - return client.subAccounts.get(1) - .then(function(subaccount){ - return subaccount.delete() - }) - .then(function(account) { - assert.equal(account, true) - }) - }); it('delete subAccounts via interface', function () { return client.subAccounts.delete(1) .then(function(accounts) { diff --git a/test/lookup.js b/test/lookup.js index ec3ab3e..8453cc2 100644 --- a/test/lookup.js +++ b/test/lookup.js @@ -13,7 +13,8 @@ describe('LookupInterface', function() { it('should lookup number', function() { return client.lookup.get('+14154305555') .then(function(number) { - assert.equal(number.numberFormat.e164, '+14154305555') + console.log(number) + assert.equal(number.format.e164, '+14154305555') assert.equal(number.phoneNumber, '+14154305555') assert.equal(number.resourceUri, '/v1/Number/+14154305555?type=carrier') }) diff --git a/test/media.js b/test/media.js index 65d1567..14676c5 100644 --- a/test/media.js +++ b/test/media.js @@ -19,7 +19,7 @@ describe('MediaInterface', function () { }); it('should get media', function () { return client.media.get('0178eb8a-461a-4fd1-bc37-13eebfdc0676') - .then(function (media) { + .then(function (res) { assert.equal(res.mediaId, '0178eb8a-461a-4fd1-bc37-13eebfdc0676') }) }); diff --git a/test/messages.js b/test/messages.js index 4071ec7..598db1b 100644 --- a/test/messages.js +++ b/test/messages.js @@ -25,7 +25,7 @@ describe('message', function () { }); it('should create message via interface', function () { - return client.messages.create('src', 'dst', 'text') + return client.messages.create({src:'src', dst:'dst', text:'text',powerpackUUID: null}) .then(function (message) { assert.equal(message.message, 'message(s) queued') }) @@ -38,6 +38,13 @@ describe('message', function () { }) }); + it('should send message via interface', function () { + return client.messages.create({src:'src', dst:'dst', text:'text'}) + .then(function(message){ + assert.equal(message.message, 'message(s) queued') + }) + }); + it('should throw error - id is required via interface', function () { return client.messages.get() @@ -47,14 +54,14 @@ describe('message', function () { }); it('should throw error - src and powerpack both not present', function () { - return client.messages.send(null, 'dst', 'text', {}, null) + return client.messages.send({src:null,dst:'dst',text:'text',powerpackUUID:null}) .catch(function (err) { assert.equal(err.message, 'Neither of src or powerpack uuid present, either one is required') }) }); it('should throw error - src and powerpack both are present', function () { - return client.messages.send('91235456917375', 'dst', 'text', {}, '916386027476') + return client.messages.send({src:'91235456917375', dst:'dst', text:'text', powerpackUUID:'916386027476'}) .catch(function (err) { assert.equal(err.message, 'Either of src or powerpack uuid, both of them are present') }) diff --git a/test/powerpacks.js b/test/powerpacks.js index e4ea231..949b71e 100644 --- a/test/powerpacks.js +++ b/test/powerpacks.js @@ -29,7 +29,7 @@ describe('PowerpackInterface', function () { return powerpack.delete() }) .then(function (result) { - assert.equal(res.response, "success") + assert.equal(result.response, "success") }) }); it('list powerpacks numbers via interface', function () { @@ -63,10 +63,9 @@ describe('PowerpackInterface', function () { client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( function (powerpack) { return powerpack.find_shortcode('4444444') - }) - .then(function (result) { - assert.equal(result.shortcode, "4444444") - }) + }).then(function (ppk) { + assert.equal(ppk.shortcode, "4444444") + }); }); it('list shortcode via interface', function () { client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then(