Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
fix(ExchangeDelegate): actually remove getEmailToken(), repair tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Jan 25, 2017
1 parent fdc582a commit 5e5bc90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockchain-wallet-client",
"version": "3.25.7",
"version": "3.26.1",
"description": "Blockchain.info JavaScript Wallet",
"homepage": "https://github.com/blockchain/my-wallet-v3",
"bugs": {
Expand Down
21 changes: 1 addition & 20 deletions src/exchange-delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,6 @@ ExchangeDelegate.prototype.isMobileVerified = function () {
return this._wallet.accountInfo.isMobileVerified;
};

ExchangeDelegate.prototype.getEmailToken = function () {
var self = this;
return API.request(
'GET',
'wallet/signed-token',
{
guid: self._wallet.guid,
sharedKey: self._wallet.sharedKey,
fields: 'email|wallet_age'
}
).then(function (res) {
if (res.success) {
return res.token;
} else {
throw new Error('Unable to obtain email verification proof');
}
});
};

ExchangeDelegate.prototype.getToken = function (partner, options) {
options = options || {};
// assert(partner, 'Specify exchange partner');
Expand All @@ -84,7 +65,7 @@ ExchangeDelegate.prototype.getToken = function (partner, options) {
// partner: partner, // Coinify doesn't support this yet
guid: this._wallet.guid,
sharedKey: this._wallet.sharedKey,
fields: `email${options.mobile ? '|mobile' : ''}|${options.walletAge ? '|wallet_age' : ''}`
fields: `email${options.mobile ? '|mobile' : ''}${options.walletAge ? '|wallet_age' : ''}`
};

if (partner) {
Expand Down
40 changes: 14 additions & 26 deletions tests/exchange_delegate_spec.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@ API =
request: (action, method, data, headers) ->
return new Promise (resolve, reject) ->
if action == 'GET' && method == "wallet/signed-token"
if emailVerified && data.fields == 'email'
resolve({success: true, token: 'json-web-token-email'})
if data.fields == 'email'
if emailVerified
resolve({success: true, token: 'json-web-token-email'})
else
resolve({success: false})
if data.fields == 'email|mobile'
if emailVerified && mobileVerified
resolve({success: true, token: 'json-web-token-email-mobile'})
else
resolve({success: false})
if emailVerified && data.fields == 'email|wallet_age'
resolve({success: true, token: 'json-web-token-email-wallet-age'})
if emailVerified && data.fields == 'mobile'
resolve({success: true, token: 'json-web-token-mobile'})
if emailVerified && data.fields == 'email|mobile'
resolve({success: true, token: 'json-web-token-email-mobile'})
else
resolve({success: false})
if action == 'GET' && method == "wallet/signed-token"
if emailVerified && mobileVerified
resolve({success: true, token: 'json-web-token'})
else
resolve({success: false})
else
Expand Down Expand Up @@ -146,36 +147,23 @@ describe "ExchangeDelegate", ->
it "should be true is users mobile is verified", ->
expect(delegate.isMobileVerified()).toEqual(true)

describe "getEmailToken()", ->
afterEach ->
emailVerified = true

it 'should get the token', (done) ->
promise = delegate.getEmailToken()
expect(promise).toBeResolvedWith('json-web-token-email-wallet-age', done);

it 'should reject if email is not verified', (done) ->
emailVerified = false
promise = delegate.getEmailToken()
expect(promise).toBeRejected(done);

describe "getToken()", ->
afterEach ->
emailVerified = true
mobileVerified = true

it 'should get the token', (done) ->
promise = delegate.getToken()
promise = delegate.getToken('partner', {mobile: true})
expect(promise).toBeResolvedWith('json-web-token-email-mobile', done);

it 'should reject if email is not verified', (done) ->
emailVerified = false
promise = delegate.getToken()
promise = delegate.getToken('partner', {mobile: true})
expect(promise).toBeRejected(done);

it 'should reject if mobile is not verified', (done) ->
emailVerified = false
promise = delegate.getToken()
mobileVerified = false
promise = delegate.getToken('partner', {mobile: true})
expect(promise).toBeRejected(done);

describe "getReceiveAddress()", ->
Expand Down

0 comments on commit 5e5bc90

Please sign in to comment.