Skip to content

Commit

Permalink
update specs for camelCase resource method names
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Aug 7, 2019
1 parent d11c807 commit a93ccea
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
33 changes: 32 additions & 1 deletion test/resources/Calls.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var telnyx = require('../../testUtils').getTelnyxMock();
var utils = require('../../lib/utils');
var expect = require('chai').expect;

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';
Expand All @@ -23,7 +24,6 @@ var COMMANDS = [
'transfer',
];


describe('Calls Resource', function() {
describe('Call Information', function() {
describe('retrieve', function() {
Expand Down Expand Up @@ -136,10 +136,15 @@ describe('Calls Resource', function() {

COMMANDS.forEach(function(command) {
describe(command, function() {
const camelCaseCommand = utils.snakeToCamelCase(command);

it('Sends the correct request', function() {
return telnyx.calls.create(callCreateData)
.then(function(response) {
const call = response.data;
call[utils.snakeToCamelCase(command)](callCommandsData[command] || {})
.then(responseFn);

return call[command](callCommandsData[command] || {})
.then(responseFn);
})
Expand All @@ -148,10 +153,36 @@ describe('Calls Resource', function() {
return telnyx.calls.create(callCreateData)
.then(function(response) {
const call = response.data;
call[utils.snakeToCamelCase(command)](callCommandsData[command] || {}, TEST_AUTH_KEY)
.then(responseFn);

return call[command](callCommandsData[command] || {}, TEST_AUTH_KEY)
.then(responseFn);
})
});

if (camelCaseCommand !== command) {
describe(camelCaseCommand, function() {
it('Sends the correct request', function() {
return telnyx.calls.create(callCreateData)
.then(function(response) {
const call = response.data;

return call[camelCaseCommand](callCommandsData[command] || {})
.then(responseFn);
})
});
it('Sends the correct request [with specified auth]', function() {
return telnyx.calls.create(callCreateData)
.then(function(response) {
const call = response.data;

return call[camelCaseCommand](callCommandsData[command] || {}, TEST_AUTH_KEY)
.then(responseFn);
})
});
})
}
});
});
});
Expand Down
32 changes: 23 additions & 9 deletions test/resources/MessagingProfiles.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var telnyx = require('../../testUtils').getTelnyxMock();
var utils = require('../../lib/utils');
var expect = require('chai').expect;

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';
Expand Down Expand Up @@ -74,15 +75,6 @@ describe('MessagingProfiles Resource', function() {
});
});

// describe('del', function() {
// it('Sends the correct request', function() {
// return telnyx.messagingProfiles.del('123')
// .then(function(response) {
// expect(response.data).to.include({id: '123'});
// })
// });
// });

describe('list', function() {
function responseFn(response) {
expect(response.data[0]).to.have.property('id');
Expand Down Expand Up @@ -212,6 +204,8 @@ describe('MessagingProfiles Resource', function() {

METHODS.forEach(function(action) {
describe(action, function() {
const camelCaseAction = utils.snakeToCamelCase(action);

it('Sends the correct request', function() {
return telnyx.messagingProfiles.create({name: 'Summer Campaign'})
.then(function(response) {
Expand All @@ -228,6 +222,26 @@ describe('MessagingProfiles Resource', function() {
.then(responseFn);
})
});

describe(camelCaseAction, function() {
it('Sends the correct request', function() {
return telnyx.messagingProfiles.create({name: 'Summer Campaign'})
.then(function(response) {
const mp = response.data;
return mp[camelCaseAction]()
.then(responseFn);
})
});
it('Sends the correct request [with specified auth]', function() {
return telnyx.messagingProfiles.create({name: 'Summer Campaign'})
.then(function(response) {
const mp = response.data;
return mp[camelCaseAction](TEST_AUTH_KEY)
.then(responseFn);
})
});

});
});
});
})
Expand Down

0 comments on commit a93ccea

Please sign in to comment.