Skip to content

Commit

Permalink
update Calls and Conferences to allow empty constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Aug 9, 2019
1 parent a669aab commit 8b65229
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/resources/Calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ module.exports = require('../TelnyxResource').extend({
response,
telnyx,
'calls',
utils.createNestedMethods(telnyxMethod, CALL_COMMANDS, getSpec(response.data.call_control_id))
utils.createNestedMethods(
telnyxMethod,
CALL_COMMANDS,
getSpec(response.data.call_control_id)
)
);
},
}),

instanceMethods: utils.createNestedMethods(telnyxMethod, CALL_COMMANDS, getSpec())
});
2 changes: 2 additions & 0 deletions lib/resources/Conferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ module.exports = require('../TelnyxResource').extend({
);
},
}),

instanceMethods: utils.createNestedMethods(telnyxMethod, CONFERENCES, getSpec())
});
22 changes: 22 additions & 0 deletions test/resources/Calls.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ describe('Calls Resource', function() {
})
});

it('Sends the correct method request [with empty resource instance]', function() {
const call = new telnyx.Call();
call.call_control_id = '3fa85f55-5717-4562-b3fc-2c963f63vga6';

call[utils.snakeToCamelCase(command)](callCommandsData[command] || {})
.then(responseFn);

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

it('Sends the correct method request [with empty resource instance and specified auth]', function() {
const call = new telnyx.Call();
call.call_control_id = '3fa85f55-5717-4562-b3fc-2c963f63vga6';

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() {
Expand Down
15 changes: 15 additions & 0 deletions test/resources/Conferences.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ describe('Calls Resource', function() {
.then(responseFn);
})
});

it('Sends the correct request [with empty resource instance]', function() {
const conference = new telnyx.Conference();
conference.call_control_id = '891510ac-f3e4-11e8-af5b-de00688a4901';

return conference[action](callConferencesData[action] || {})
.then(responseFn);
});
it('Sends the correct request [with empty resource instance and specified auth]', function() {
const conference = new telnyx.Conference();
conference.call_control_id = '891510ac-f3e4-11e8-af5b-de00688a4901';

return conference[action](callConferencesData[action] || {}, TEST_AUTH_KEY)
.then(responseFn);
});
});
});
});
Expand Down

0 comments on commit 8b65229

Please sign in to comment.