Skip to content

Commit

Permalink
Enables subaccount when it is created
Browse files Browse the repository at this point in the history
Fixes create subaccount method to enable subaccount when creating it.
  • Loading branch information
Abhishek-plivo authored and plivo-sdks committed Jun 26, 2018
1 parent 067e0c8 commit 29803fd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ gulp.task('test', ['pre-test'], function (cb) {
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
mochaErr = err;
throw(err)
})
.pipe(istanbul.writeReports())
.on('end', function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/resources/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class SubaccountInterface extends PlivoResourceInterface {
params.name = name;

if (typeof enabled === 'boolean') {
params.enabled = enabled;
params.enabled = enabled.toString();
}

return super.create(params);
Expand Down
31 changes: 29 additions & 2 deletions test/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,35 @@ describe('Account', function () {
})
});

it('should create subAccount via interface', function() {
return client.subAccounts.create('Test Subaccount', true);
it('should not create subAccount without subAccount name and throw error', function() {
return client.subAccounts.create()
.catch(function(errorResponse) {
assert.equal(errorResponse, 'Error: Missing mandatory field: name')
})
})

it('should create enabled subAccount via interface', function() {
return client.subAccounts.create('Test Subaccount', true)
.then(function(genericResponse) {
assert.equal(genericResponse.message, 'created')
assert.equal(genericResponse.authId, 'SANDLHYZBIZMU4ZDEXNM')
})
})

it('should create disabled subAccount via interface', function() {
return client.subAccounts.create('Test Subaccount', false)
.then(function(genericResponse) {
assert.equal(genericResponse.message, 'created')
assert.equal(genericResponse.authId, 'SANDLHYZBIZMU4ZDEXNM')
})
})

it('should create disabled subAccount via interface', function() {
return client.subAccounts.create('Test Subaccount')
.then(function(genericResponse) {
assert.equal(genericResponse.message, 'created')
assert.equal(genericResponse.authId, 'SANDLHYZBIZMU4ZDEXNM')
})
})

it('should get subAccount by id via interface', function () {
Expand Down

0 comments on commit 29803fd

Please sign in to comment.