diff --git a/src/request.js b/src/request.js index f20d9e2..fc05884 100644 --- a/src/request.js +++ b/src/request.js @@ -9,6 +9,7 @@ class Request { // Account accountSetup(key, secret, flags) { + key = key.toLowerCase(); this._verifyCredentials(key, secret, this.response.accountSetup(this.config, key, secret, flags).bind(this.response)); } diff --git a/tests/request.js b/tests/request.js index c3b09df..50614e0 100644 --- a/tests/request.js +++ b/tests/request.js @@ -36,15 +36,24 @@ describe('Request', () => { }); describe('.accountSetup', () => { - it('should verifiy the credentials', sinon.test(function(){ + beforeEach(() => { nexmo = {}; nexmo.account = sinon.createStubInstance(Account); client.instanceWith.returns(nexmo); response.accountSetup.returns(()=>{}); + }); + + it('should verify the credentials', sinon.test(function(){ request.accountSetup('123', 'abc', false); expect(nexmo.account.checkBalance).to.have.been.called; expect(response.accountSetup).to.have.been.called; })); + + it('should convert API key to lower case', sinon.test(function(){ + request.accountSetup('ABC123', 'abc', false); + expect(nexmo.account.checkBalance).to.have.been.called; + expect(response.accountSetup).to.have.been.calledWith(config, 'abc123', 'abc', false); + })); }); describe('.accountInfo', () => {